<template>
  <div class="app-container">
  		
			
  	<div class="policy_box_top">
  				<p class="backgo" @click="go_backs"><i class="iconfont icon-left"></i>返回</p>
    			<i class="iconfont icon-baoxianchanpin"></i>
    			<span v-if="this.policyItemId&&!this.$route.query.iscopy">政策编辑</span>
    			<span v-else-if="this.policyItemId&&this.$route.query.iscopy">政策复制</span>
    			<span v-else>政策新建</span>
    			
    </div>
    <div class="policy-box">
      <el-form ref="data" :model="data" label-width="120px" v-loading="loading" :rules="rules">
        <div v-for="(obj,ix) in newArr" :key="ix">
        
        <div style="position:relative;padding-left:140px;overflow-x:hidden" v-if="obj.conditionType == 1" :class="toExpand?'show':'hide'">
            <div class="form_left">
              <span class="form-title">
                			车辆条件
              </span>
            </div>
            <div class="form_right">
            	<p class="nodata" v-if="allhide1">暂无数据</p>
            	 <div v-for="(item,index) in policyFilter" :key="item.id" v-show="item.add_isShow">
              <div v-if="item.conditionType ==1">
                <el-form-item :label="item.displayName">
                  <div style="padding-left:30px;">
                  <template v-if="item.displayType == 1">
                    <el-checkbox-group v-model="temarr[index].tarr" @change='checkGrop($event,index)'>
                      <el-checkbox :disabled='isdisable'  v-for="obj in item.items" :checked="obj.isChecked" :key="obj.id" :label="obj.id" name="type">{{obj.displayName}}</el-checkbox>
                    </el-checkbox-group>
                    <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                     
                  </template>
                  
                  <template v-else-if="item.displayType == 2">
      
                    <el-radio-group v-model="item.value" @change='radioGrop($event,index)'>
                      <el-radio :disabled='isdisable' v-for="obj in item.items" :checked="obj.isChecked" :key="obj.id" :label="obj.id">{{obj.displayName}}
                      
                      </el-radio>
                    	
                    
                    </el-radio-group>
                   
                     <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                  </template>
                  <template v-else-if="item.displayType == 3">

                    <minmax :isdisable="isdisable" :remarks="item.remarks" :text="text" :model="item.value" v-on:total="getTotal($event,index)" v-on:error="getError($event,item.id)"></minmax>

                    <div v-for="(elem,ins) in item.extends" :key="ins" style="display:inline-block">
                      <el-select :disabled='isdisable' v-if="elem.extendValues.length > 0" v-model="elem.value" @change="selectChangeextends($event,index)" placeholder="请选择" class="wd230_110" size="mini">
                        <el-option size="mini" v-for="last in elem.extendValues" :checked="last.isChecked" :key="last.id" :label="last.displayName" :value="last.id">
                        </el-option>
                      </el-select>
                      {{elem.remarks}}
                    </div>
                   <!-- <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>-->
                  </template>
                  <template v-else-if="item.displayType == 4">
                    <el-select :disabled='isdisable' v-if="item.items.length > 0" v-model="temarr[index].tarr" @change="selectChange($event,index)" placeholder="请选择" class="wd230" size="mini">
                      <el-option size="mini" v-for="last in item.items" :key="last.id" :label="last.displayName" :value="last.id">
                      </el-option>
                    </el-select>
                     <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                  </template>
                  <template v-else-if="item.displayType == 6">
                    <el-checkbox-group :disabled='isdisable' v-model="temarr[index].tarr" @change='quyuGrop($event,index)'>
                      <el-checkbox v-for="obj in regions" :key="obj.regionId" :checked="obj.isChecked" :label="obj.regionId" name="type">{{obj.regionName}}</el-checkbox>

                    </el-checkbox-group>
										 <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                  </template>
                  <template v-else-if="item.displayType == 7">
                    <el-date-picker :disabled='isdisable' size='mini' v-model="item.dateValues" value-format="yyyy-MM-dd" type="daterange" range-separator="到" start-placeholder="开始日期" end-placeholder="结束日期">
                    </el-date-picker>
                     <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                  </template>
                  
                  <template v-else-if="item.displayType == 9">
                    <!--<el-input @blur="getval($event,index)" v-model="item.value" size="mini" style="width:230px;" :disabled='isdisable' placeholder="请输入内容"></el-input>
                  	<span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>-->
                  	<addModel :lists="item.addsvalue" :isdisable='isdisable' :indexs="index" :labels="item.displayName" @adds="addmodel" @removelist="removes"></addModel>
           
                  </template>
                  
                  <template v-else-if="item.displayType == 5">
                    	  <ztree-select :disabled='isdisable'  v-model="arrdefaults"  @change="selectChange_tree(arrdefaults,index,item.treeItems)"   multiple :treedata="item.treeItems" :childprops="childprops"></ztree-select>
                  </template>
                  
                   <template v-if="item.displayType == 5">
	              	 	<el-form-item v-if="namearr.length!=0">
	              	 	 	 	<div class="carname">
	              	 	 	 		<p v-for="item in namearr">{{item}}</p>
	              	 	 		</div>
	              	 	 	 	
	              	 	 </el-form-item>
	              	 	 
	                  </template>
                  
                  
                  </div>
                </el-form-item>
              </div>
            </div>
           			<div class='isExpand_ben' v-if="!toExpand">
										<p class="more" @click='isExpand'>更多条件 <i class="iconfont icon-bottom"> </i></p>
								</div>
								<div class='isExpand_ben' v-if="toExpand">
										<p class="more" @click='isExpand'>收起 <i class="iconfont icon-up"></i></p>
								</div>
            </div>

          </div>
					<div style="margin-top:30px;">
						
					</div>
          <div style="position:relative;padding-left:140px;overflow-x:hidden;height:auto;" v-if="obj.conditionType == 2" :class="Underwriting_toExpand?'Expandshow':'Expandhide'">
             <div class="form_left">
              <span class="form-title">
                 		 承保条件
              </span>
            </div>
            
            <div class="form_right">
            	<p class="nodata" v-if="allhide2">暂无数据</p>
            	 <div v-for="(item,index) in policyFilter" :key="item.id" v-show="item.add_isShow">
              <div v-if="item.conditionType ==obj.conditionType">
              	
                <el-form-item :label="item.displayName" label-width="130px">
                   <div style="padding-left:30px;">
                  <template v-if="item.displayType == 1">
                  	<template v-if="item.id==67">
                  		  <el-select class="selets_models" :disabled='isdisable' v-model="insurance_model" multiple placeholder="请选择" size="mini" @change="getinsurance_model(insurance_model,index)">
											    <el-option
											      v-for="obj in item.items"
											      :key="obj.id"
											      :label="obj.displayName"
											      :value="obj.id">
											    </el-option>
											  </el-select>
											  <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                  	</template>
                  	<template v-else-if="item.id==75">
                  		  <el-select class="selets_models"  :disabled='isdisable' v-model="no_insurance_model" multiple placeholder="请选择" size="mini" @change="no_getinsurance_model(no_insurance_model,index)">
											    <el-option
											      v-for="obj in item.items"
											      :key="obj.id"
											      :label="obj.displayName"
											      :value="obj.id">
											    </el-option>
											  </el-select>
											   <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                  	</template>
                  		<template v-else>
                  			 <el-checkbox-group :disabled='isdisable' v-model="temarr[index].tarr" @change='checkGrop($event,index)'>
                      		<el-checkbox v-for="obj in item.items" :key="obj.id" :checked="obj.isChecked" :label="obj.id" name="type">{{obj.displayName}}</el-checkbox>
                   			 </el-checkbox-group>
                  			 <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                  		</template>
                   
                  </template>
                  <template v-else-if="item.displayType == 2">
                  	
                  	
                    <el-radio-group :disabled='isdisable' v-model="temarr[index].tarr" @change='radioGrop($event,index)'>
                      <el-radio v-for="obj in item.items" :key="obj.id" :checked="obj.isChecked" :label="obj.id">{{obj.displayName}}</el-radio>
                    </el-radio-group>
                    
                     <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                    
                    
                    
                  </template>
                  <template v-else-if="item.displayType == 3">
                    <template v-if="item.id == 34">
                      <minmax :isdisable="isdisable" :text="text" :maxnum="maxnum" :model="item.value" v-on:total="getTotal($event,index)" v-on:error="getError($event,item.id)"></minmax>
											 <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                    </template>
                    <template v-else>
                      <minmax :isdisable="isdisable" :text="text" :remarks="item.remarks" :model="item.value" v-on:total="getTotal($event,index)" v-on:error="getError($event,item.id)"></minmax>
                   		<!-- <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>111-->
                    </template>

                    <div v-for="(elem,ins) in item.extends" :key="ins" style="display:inline-block">
                     <!-- {{elem.value}} -->
                       <el-select :disabled='isdisable' v-if="elem.extendValues.length > 0" v-model="elem.value" @change="selectChangeextends($event,index)" placeholder="请选择" class="wd230" size="mini">
                        <el-option size="mini" v-for="last in elem.extendValues" :checked="last.isChecked" :key="last.id" :label="last.displayName" :value="last.id">
                        </el-option>
                      </el-select>
                      {{elem.remarks}}
                      <!-- <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span> -->
                    </div>
                    <span v-if="item.id == 34 &&filters[index].conditionValue !=='-'">大于等于{{filters[index].conditionValue | dayu}} 折&nbsp;&nbsp;小于等于{{filters[index].conditionValue | xiaoyu}}折</span>
                  </template>
                  <template v-else-if="item.displayType == 4">
                    <el-select :disabled='isdisable' v-if="item.items.length > 0" v-model="temarr[index].tarr" @change="selectChange($event,index)" placeholder="请选择" class="wd230" size="mini">
                      <el-option size="mini" v-for="last in item.items" :key="last.id" :label="last.displayName" :value="last.id">
                      </el-option>
                    </el-select>
                    <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                  </template>
                  <template v-else-if="item.displayType == 6">
                    <!--<div  class="checkregion">
                      <el-checkbox label="1" v-model="bdqcheck" name="type" @change="bdq">
                        本地区（工号所属地区）
                        <span v-for="obj in regions" :key="obj.regionId">&nbsp;&nbsp;&nbsp;{{obj.fullName}}</span>
                      </el-checkbox>
                    </div>
                    <div>
                      <el-checkbox label="2" name="type" v-model="bscheck">本省其他地区</el-checkbox>
                      <el-button type="text" @click="bensheng">点击选择</el-button>
                    </div>
                    <div>
                      <el-checkbox label="3" name="type" v-model="wscheck">外省其他地区</el-checkbox>
                      <el-button type="text" @click="waisheng">点击选择</el-button>
                    </div>
                    <div>
                      <el-checkbox label="4" v-model="qtcheck" name="type">未知区域（适用于未上牌车辆）</el-checkbox>
                    </div>-->
										<div class="checkregion">
											<el-checkbox-group :disabled='isdisable' v-model="checkboxGroup1" class="checkregion_one" @change="pickcheckbox(checkboxGroup1,index)">
									      <el-checkbox v-for="city in cities" :label="city.label" :key="city.label"  @change="picktf($event,city.label)">
									      	{{city.name}}</el-checkbox>
									   </el-checkbox-group>
									   <p class="posone" :class="isdisable?'posone_true':'posone_false'">
									   	<!--<el-tooltip :content="textdires" placement="bottom" effect="light">-->
											 <span>{{textdires}}</span>
									   <!--	</el-tooltip>-->
									   </p>
									   <template v-if="isdisable">
										   	<!--<el-select v-model="checkedBs" :disabled='isdisable' multiple  collapse-tags placeholder="请选择地区" class="postwo" size="mini"
										   		@change="benshengSave(index)">
											    <el-option
											    	:disabled='isdisable'
											      v-for="bsitem in bslist"
											      :key="bsitem.id"
											      :label="bsitem.title"
											      :value="bsitem.id">
											    </el-option>
											  </el-select>-->
											   <ztree-select  :viewinfo='isdisable' class="postwo" v-model="checkedBs"  @change="benshengSave(index)"   multiple :treedata="bslist" :childprops="waichildprops"></ztree-select>
             
											   <ztree-select :viewinfo='isdisable'   class="posthree" v-model="checkedWs"  @change="waishengSave(index)"   multiple :treedata="wslist" :childprops="waichildprops"></ztree-select>
             
									   </template>
									   <template v-else>
										   <!--	<el-button type="text" @click="bensheng" class="postwo">点击选择</el-button>-->
										   	<!--<el-select v-model="checkedBs" multiple  collapse-tags placeholder="请选择地区" class="postwo" size="mini"
										   		@change="benshengSave(index)">
											    <el-option
											    	:disabled='isdisable'
											      v-for="bsitem in bslist"
											      :key="bsitem.id"
											      :label="bsitem.title"
											      :value="bsitem.id">
											    </el-option>
											  </el-select>-->
											  <ztree-select :viewinfo='isdisable'  class="postwo" v-model="checkedBs"  @change="benshengSave(index)"   multiple :treedata="bslist" :childprops="waichildprops"></ztree-select>
             
											   <ztree-select :viewinfo='isdisable' class="posthree" v-model="checkedWs"  @change="waishengSave(index)"   multiple :treedata="wslist" :childprops="waichildprops"></ztree-select>
             
										    <!--<el-button type="text" @click="waisheng" class="posthree">点击选择</el-button> -->
									   </template>
									     
										</div>
                    <!--<el-dialog title="本省其他区域" :visible.sync="benshengHidden" width="500px" :close-on-click-modal='false' center>
                      <div>
                        <el-checkbox :indeterminate="isIndeterminate" v-model="bscheckAll" :disabled='isdisable' @change="checkallbs">全选</el-checkbox>
                        <div style="margin: 15px 0;"></div>
                        <el-checkbox-group v-model="checkedBs" @change="bsChange">
                          <el-checkbox v-for="bsitem in bslist" :disabled='isdisable' :label="bsitem.id" :key="bsitem.id">{{bsitem.title}}</el-checkbox>
                        </el-checkbox-group>
          						
          
          
                      </div>
                      <span slot="footer" class="dialog-footer">
                        <el-button type="primary" @click="benshengSave(index)">确 定</el-button>
                      </span>
                    </el-dialog>-->
                    <!--<el-dialog title="外省其他区域" :visible.sync="waishengHidden" width="500px" :close-on-click-modal='false' center>
                      <div>
                        <el-select v-model="wsselect" @change="wsselectChange($event,index)" placeholder="请选择" class="wd230" size="mini">
                          <el-option size="mini" :disabled='isdisable' v-for="objs in wslist" :key="objs.id" :label="objs.title" :value="objs.id">
                          </el-option>
                        </el-select>
                        <div>
                          <el-checkbox :indeterminate="wsisIndeterminate" v-model="wscheckAll" :disabled='isdisable' @change="checkallws">全选</el-checkbox>
                          <div style="margin: 15px 0;"></div>
                          <el-checkbox-group v-model="checkedWs" @change="wsChange">
                            <el-checkbox :disabled='isdisable' v-for="wsitem in wsarr" :label="wsitem.key" :key="wsitem.key">{{wsitem.value}}</el-checkbox>
                          </el-checkbox-group>
                        </div>
                      </div>
                      <span slot="footer" class="dialog-footer">
                        <el-button type="primary" @click="waishengSave(index)">确 定</el-button>
                      </span>
                    </el-dialog>-->
                     <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                  </template>
                  <template v-else-if="item.displayType == 7">
                    <!--<el-date-picker :disabled='isdisable' size='mini' v-model="item.dateValues" value-format='yyyy/MM/dd' type="daterange" @change='dateChange($event,index)' range-separator="到" start-placeholder="开始日期" end-placeholder="结束日期">
                    </el-date-picker>
                    <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>-->
                  
                    <el-date-picker
                    	class="datesclass"
                    	@change="dateChange($event,index)"
                    	prefix-icon=" "
									      v-model="item.dateValues[0]"
									      :disabled='isdisable'
									      type="date"
									      size='mini'
									      value-format='yyyy/MM/dd'
									      placeholder="选择开始日期">
									    </el-date-picker>
									    <span>到</span>
                     <el-date-picker
                     	@change="dateChange($event,index)"
                     		class="datesclass"
                     		prefix-icon=" "
									      v-model="item.dateValues[1]"
									      :disabled='isdisable'
									      type="date"
									      size='mini'
									      value-format='yyyy/MM/dd'
									      placeholder="选择结束日期">
									    </el-date-picker>
									     <el-checkbox v-model="item.checkedsnow" @change="radiochange($event,index)">不限</el-checkbox>
                     <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                     
                  </template>
                   <template v-else-if="item.displayType == 9">
                    <el-input @blur="getval($event,index)" v-model="item.value" size="mini" style="width:230px;" :disabled='isdisable' placeholder="请输入内容"></el-input>
                 		 <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                   </template>
                 
                  <template v-else-if="item.displayType == 5">
                    	  <ztree-select :disabled='isdisable' v-model="arrdefaults"  @change="selectChange_tree(arrdefaults,index,item.treeItems)"   multiple :treedata="item.treeItems" :childprops="childprops"></ztree-select>
                  			 <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                  </template>
                   <template v-if="item.displayType == 5">
	              	 	<el-form-item v-if="namearr.length!=0">
	              	 	 	 	<div class="carname">
	              	 	 	 		<p v-for="item in namearr">{{item}}</p>
	              	 	 		</div>
	              	 	 	 	
	              	 	 </el-form-item>
	              	 	  <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
	                  </template>
                 
                  </div>
                </el-form-item>
              </div>
            </div>
         			 <div class='isExpand_ben' v-if="!Underwriting_toExpand">
								<p class="more" @click='Underwriting_isExpand'>更多条件 <i class="iconfont icon-bottom"> </i></p>
							</div>
								<div class='isExpand_ben' v-if="Underwriting_toExpand">
									<p class="more" @click='Underwriting_isExpand'>收起 <i class="iconfont icon-up"></i></p>
								
							</div>
            </div>

          </div>
        	 <div style="margin-top:30px;">
						
					</div>
          <div v-if="obj.conditionType == 3">
            <div class="form-top">
              <i class="iconfont icon-baoxianchanpin"></i>
              <span class="form-title">
                其他条件
              </span>
            </div>
            <div v-for="(item,index) in policyFilter" :key="item.id">
              <div v-if="item.conditionType ==obj.conditionType">
                <el-form-item :label="item.displayName">
                   <div style="padding-left:30px;">
                  <template v-if="item.displayType == 1">
                    <el-checkbox-group :disabled='isdisable' v-model="temarr[index].tarr" @change='checkGrop($event,index)'>
                      <el-checkbox v-for="obj in item.items" :key="obj.id" :checked="obj.isChecked" :label="obj.id" name="type">{{obj.displayName}}</el-checkbox>

                    </el-checkbox-group>
                  </template>
                  <template v-else-if="item.displayType == 2">
                    <el-radio-group :disabled='isdisable' v-model="temarr[index].tarr" @change='radioGrop($event,index)'>
                      <el-radio v-for="obj in item.items" :key="obj.id" :checked="obj.isChecked" :label="obj.id">{{obj.displayName}}</el-radio>
                    </el-radio-group>
                  </template>
                  <template v-else-if="item.displayType == 3">
                    <minmax :isdisable="isdisable" :text="text" :model="item.value" v-on:total="getTotal($event,index)" v-on:error="getError($event,item.id)($event,item.id)"></minmax>

                    <div v-for="(elem,ins) in item.extends" :key="ins" style="display:inline-block">
                      <el-select :disabled='isdisable' v-if="elem.extendValues.length > 0" v-model="elem.value" @change="selectChangeextends($event,index)" placeholder="请选择" class="wd230" size="mini">
                        <el-option size="mini" v-for="last in elem.extendValues" :checked="last.isChecked" :key="last.id" :label="last.displayName" :value="last.id">
                        </el-option>
                      </el-select>
                      {{elem.remarks}}

                    </div>
                  </template>
                  <template v-else-if="item.displayType == 4">
                    <el-select :disabled='isdisable' v-if="item.items.length > 0" v-model="temarr[index].tarr" @change="selectChange($event,index)" placeholder="请选择" class="wd230" size="mini">
                      <el-option size="mini" v-for="last in item.items" :key="last.id" :label="last.displayName" :value="last.id">
                      </el-option>
                    </el-select>
                  </template>
                  <template v-else-if="item.displayType == 6">
                    投放区域
                  </template>
                  <template v-else-if="item.displayType == 7">
                   <el-date-picker
                    	class="datesclass"
                    	@change="dateChange($event,index)"
                    	prefix-icon=" "
									      v-model="item.dateValues[0]"
									      :disabled='isdisable'
									      type="date"
									      size='mini'
									      value-format='yyyy/MM/dd'
									      placeholder="选择开始日期">
									    </el-date-picker>
									    <span>到</span>
                     <el-date-picker
                     	@change="dateChange($event,index)"
                     		class="datesclass"
                     		prefix-icon=" "
									      v-model="item.dateValues[1]"
									      :disabled='isdisable'
									      type="date"
									      size='mini'
									      value-format='yyyy/MM/dd'
									      placeholder="选择结束日期">
									    </el-date-picker>
									     <el-checkbox v-model="item.checkedsnow" @change="radiochange($event,index)">不限</el-checkbox>
                     <span v-if="item.remarks">&nbsp;&nbsp;{{item.remarks}}</span>
                    
                  </template>
                     <template v-else-if="item.displayType == 9">
                    <el-input @blur="getval($event,index)" v-model="item.value" size="mini" style="width:230px;" :disabled='isdisable' placeholder="请输入内容"></el-input>
                  </template>
                   </div>
                </el-form-item>
              </div>
            </div>
          </div>
        </div>
        <div style="margin-top:30px;">
						
				</div>
       <div style="position:relative;padding-left:140px;overflow-x:hidden">
       		<div class="form_left">
              <span class="form-title">
                 		 佣金设置
              </span>
           </div>
        <div class="form_right">
        	<div class="form_right_one">
        		 <el-form-item label-width="120px" label="保费类型">
		           <div style="padding-left:30px;">
		          <el-radio-group :disabled='isdisable' v-model="data.upperPremiumType" size="mini" @change="premiumchange">
		          	<el-radio-button label="1" >净保费</el-radio-button>
		            <el-radio-button label="0" >全保费</el-radio-button> 
		          </el-radio-group>
		           </div>
		        </el-form-item>
        	</div>
       <div class="form_right_one">
       	<el-form-item label-width="120px" label="返佣类型">
           <div style="padding-left:30px;">
          <el-radio-group :disabled='isdisable' v-model="data.brokerageBusinessType" size="mini" @change="Maidchange">
            <el-radio-button label="0">百分比</el-radio-button>
            <el-radio-button label="1">元</el-radio-button>
          </el-radio-group>
           </div>
        </el-form-item>
      
       	</div>
       	<div class="form_right_one">
       	<el-form-item label-width="120px" label="是否扣点">
 		<div style="padding-left:30px;">
          <el-radio-group :disabled='isdisable' v-model="data.chargeType" size="mini" @change="Pointschange">
            <el-radio-button label="1">是</el-radio-button>
            <el-radio-button label="0">否</el-radio-button>
          </el-radio-group>
 	</div>
        </el-form-item>
       
       	</div>
   	<div style="clear:both;">
   		
   	</div>     
   
       
       <el-form-item v-if="this.stream != '2'" label-width="120px" label="交强险设置" class="is-required" prop='yongjin'>
           <div style="padding-left:30px;">
		          <span class="ft13">佣金</span>
		          <el-input :disabled='isdisable' @focus="focusselect($event)" type="text" v-model="data.upperBrokerageTraffic" @change="clearNoNum($event,'upperBrokerageTraffic',100)" class="wd80" size='mini' placeholder="数值"></el-input>
		          <span class="ft13">{{data.brokerageBusinessType =='0'?'%':'元'}}&nbsp;&nbsp;&nbsp;&nbsp; 奖励
		          </span>
		          <el-input :disabled='isdisable' @focus="focusselect($event)" type="text" v-model="data.upperRewardTraffic" class="wd80" @change="clearNoNum($event,'upperRewardTraffic',100)" size='mini' placeholder="数值"></el-input>
		          <span class="ft13">{{data.brokerageBusinessType =='0'?'%':'元'}}</span>
		          {{yongjin}}
		          <div style="display:none">
		            <el-input v-model="data.yongjin" type='hidden'></el-input>
		          </div>
           </div>
        </el-form-item>
        <el-form-item v-if="this.stream != '2'" label-width="120px" label="商业险设置" class="is-required" prop='shangye'>
           <div style="padding-left:30px;">
          <span class="ft13">佣金</span>
          <el-input :disabled='isdisable' @focus="focusselect($event)" type="text" v-model="data.upperBrokerageBusiness" @change="clearNoNum($event,'upperBrokerageBusiness',100)" class="wd80" size='mini' placeholder="数值"></el-input>
          <span class="ft13"> {{data.brokerageBusinessType =='0'?'%':'元'}}&nbsp;&nbsp;&nbsp;&nbsp; 奖励
          </span>
          <el-input :disabled='isdisable' @focus="focusselect($event)" type="text" v-model="data.upperRewardBusiness" @change="clearNoNum($event,'upperRewardBusiness',100)" class="wd80" size='mini' placeholder="数值"></el-input>
          <span class="ft13"> {{data.brokerageBusinessType =='0'?'%':'元'}}</span>
          {{shangye}}
          <div style="display:none">
            <el-input v-model="data.shangye" type='hidden'></el-input>
          </div>
           </div>
        </el-form-item>
        
          <el-form-item v-if="this.stream != '2'" label-width="120px" label="车船税设置" class="is-required" prop='chechuan'>
           <div style="padding-left:30px;">
          <span class="ft13">佣金</span>
          <el-input :disabled='isdisable' @focus="focusselect($event)" type="text" v-model="data.upperBrokerageVehicleTax" @change="clearNoNum($event,'upperBrokerageVehicleTax',100)" class="wd80" size='mini' placeholder="数值"></el-input>
          <span class="ft13"> {{data.brokerageBusinessType =='0'?'%':'元'}}
          </span>
           {{chechuan}}
          <div style="display:none">
            <el-input v-model="data.chechuan" type='hidden'></el-input>
          </div>
           </div>
        </el-form-item>
        <div  style="width:100%;padding:0 50px">
        	 <div v-if="this.stream == '2'" style="width:100%;">
					<table class="util-table" >
							<tr>
								<th rowspan="2" width="18%">下游</th>
								<th colspan="2" width="30%">交强险</th>
								<th colspan="2" width="30%" >商业险</th>
								<th width="12%">车船税</th>
								<template v-if="!isdisable">
									<th rowspan="2" width="10%" v-if="data.extends">操作</th>
								</template>
								
							</tr>
							<tr>
								<th width="100">佣金</th>
								<th width="100">奖励</th>
								<th width="100">佣金</th>
								<th width="100">奖励</th>
								<th width="100" style="padding:0;">佣金</th>
							</tr>
							
							<tr>
								<td>通用</td>
								<td :class="data.isbackshow?'backshows':''">
									<span :class="data.change1?'ischange1':''">
											<span v-if="data.upperChargeType==1">-</span>
										<input :class="{'isfrontshow':data.isfront,'isdis':isdisable}" :disabled="isdisable" @change='getchange_num($event,"lowerBrokerageTraffic",data.brokerageBusinessType)'
											v-model="data.lowerBrokerageTraffic" @focus="focusselect($event)" type="text" class="inputset"/>
										<span v-if="data.brokerageBusinessType==0">%</span>
										<span v-else>元</span>
									</span>
								</td>
								<td :class="data.isbackshow?'backshows':''">
									<span :class="data.change2?'ischange2':''">
										<span v-if="data.upperChargeType==1">-</span>
									<input :disabled="isdisable" :class="{'isfrontshow':data.isfront,'isdis':isdisable}" @change='getchange_num($event,"lowerRewardTraffic",data.brokerageBusinessType)' 
										v-model="data.lowerRewardTraffic" @focus="focusselect($event)" type="text" class="inputset"/>
									
									<span v-if="data.brokerageBusinessType==0">%</span>
									<span v-else>元</span>
									</span>
								</td>
								<td :class="data.isbackshow?'backshows':''">
									<span :class="data.change3?'ischange3':''">
										<span v-if="data.upperChargeType==1">-</span>
									<input :disabled="isdisable" @focus="focusselect($event)"
										:class="{'isseconshow':data.issecon,'isdis':isdisable}"
										 @change='getchange_num($event,"lowerBrokerageBusiness",data.brokerageBusinessType)' 
										v-model="data.lowerBrokerageBusiness"  type="text" class="inputset"/>
									
									<span v-if="data.brokerageBusinessType==0">%</span>
									<span v-else>元</span>
									</span>
								</td>
								<td :class="data.isbackshow?'backshows':''">
									<span :class="data.change4?'ischange4':''">
										<span v-if="data.upperChargeType==1">-</span>
									<input :disabled="isdisable" @focus="focusselect($event)" :class="{'isseconshow':data.issecon,'isdis':isdisable}" @change='getchange_num($event,"lowerRewardBusiness",data.brokerageBusinessType)' 
										v-model="data.lowerRewardBusiness"  type="text" class="inputset"/>

									<span v-if="data.brokerageBusinessType==0">%</span>
									<span v-else>元</span>
									</span>
								</td>
								
									<td :class="data.isbackshow?'backshows':''">
										<span :class="data.change5?'ischange5':''">
										<span v-if="data.upperChargeType==1">-</span>
										<input :disabled="isdisable" @focus="focusselect($event)" :class="{'isthreeshow':data.isthree,'isdis':isdisable}" @change='getchange_num($event,"lowerBrokerageVehicleTax",data.brokerageBusinessType)' 
											v-model="data.lowerBrokerageVehicleTax"  type="text" class="inputset"/>
	
										<span v-if="data.brokerageBusinessType==0">%</span>
										<span v-else>元</span>
									</span>
										
									</td>
								<td></td>
							</tr>
							<tr v-for="(item,index) in data.extends">
								<td class="yichu">
									<!-- <el-tooltip placement="bottom" effect="light" v-if="item.describe">
										  <div slot="content">
										  	<p class="describe_text" v-for="onelist in item.describe">{{onelist}}</p>
										  </div>
										  	<span ref="tabindexchild">子机构（{{item.describe.length}}）</span>
												<span ref="tabindexchild">{{item.describe[0]}}</span>
										</el-tooltip> -->
										<span ref="tabindexchild" v-if="item.describe">{{item.describe[0]}}</span>
										<p class="describe_text" v-else>暂无数据</p>
										<!-- <el-tooltip placement="bottom" effect="light" v-else>
										  <div slot="content">
										  	<p class="describe_text">暂无数据</p>
										  </div>
									</el-tooltip> -->
									</td>
								<td :class="item.isbackshow?'backshows':''">
									<span :class="item.change1?'ischange1':''">
									<span v-if="data.upperChargeType==1">-</span>
									
									<input @focus="focusselect($event)" :disabled="isdisable" @change='getchange_extendnum($event,index,"lowerBrokerageTraffic",data.brokerageBusinessType)'
										:class="{'isfrontshow':item.isfront,'isdis':isdisable}"
										  v-model="item.lowerBrokerageTraffic"  type="text" class="inputset"/>
									<span v-if="data.brokerageBusinessType==0">%</span>
									<span v-else>元</span>
									</span>
								</td>
								
								<td :class="item.isbackshow?'backshows':''">
									<span :class="item.change2?'ischange2':''">
										<span v-if="data.upperChargeType==1">-</span>
									<input @focus="focusselect($event)" :disabled="isdisable" @change='getchange_extendnum($event,index,"lowerRewardTraffic",data.brokerageBusinessType)'
										:class="{'isfrontshow':item.isfront,'isdis':isdisable}" v-model="item.lowerRewardTraffic"  type="text" class="inputset"/>
									
									<span v-if="data.brokerageBusinessType==0">%</span>
									<span v-else>元</span>
									</span>
								</td>
								
									<td :class="item.isbackshow?'backshows':''">
									<span :class="item.change3?'ischange3':''">
										<span v-if="data.upperChargeType==1">-</span>
									<input @focus="focusselect($event)" :disabled="isdisable" @change='getchange_extendnum($event,index,"lowerBrokerageBusiness",data.brokerageBusinessType)'
										:class="{'isseconshow':item.issecon,'isdis':isdisable}"
									 v-model="item.lowerBrokerageBusiness"  type="text" class="inputset"/>
									
									<span v-if="data.brokerageBusinessType==0">%</span>
									<span v-else>元</span>
									</span>
								</td>
								<td :class="item.isbackshow?'backshows':''">
									<span :class="item.change4?'ischange4':''">
										<span v-if="data.upperChargeType==1">-</span>
									<input @focus="focusselect($event)" :disabled="isdisable" @change='getchange_extendnum($event,index,"lowerRewardBusiness",data.brokerageBusinessType)'
										:class="{'isseconshow':item.issecon,'isdis':isdisable}" v-model="item.lowerRewardBusiness"  type="text" class="inputset"/>
								
									<span v-if="data.brokerageBusinessType==0">%</span>
									<span v-else>元</span>
									</span>
								</td>
								<td :class="item.isbackshow?'backshows':''">
									<span :class="item.change5?'ischange5':''">
										<span v-if="data.upperChargeType==1">-</span>
									<input @focus="focusselect($event)" :disabled="isdisable" @change='getchange_extendnum($event,index,"lowerBrokerageVehicleTax",data.brokerageBusinessType)'
										:class="{'isthreeshow':item.isthree,'isdis':isdisable}" v-model="item.lowerBrokerageVehicleTax"  type="text" class="inputset"/>
								
									<span v-if="data.brokerageBusinessType==0">%</span>
									<span v-else>元</span>
									</span>
									
								</td>
								<td class="addbtn" v-if="!isdisable">
									<span class="addbtnedits" @click="editaddlowpolic(item,index)">编辑</span>
									<el-popover
								  placement="bottom-end"
								  width="250"
								  :ref='"aa"+index'
								  v-model="item.delete_show">
								  <p class="candeletes">确定删除吗？</p>
								  <div style="text-align: right; margin: 0">
								    <el-button size="mini" type="text" @click="deletefalse('aa'+index)">取消</el-button>
								    <el-button type="primary" size="mini" @click="deletepolicy(item,index,'aa'+index)">确定</el-button>
								  </div>
								  <span class="tablescont_right_delete" slot="reference" ref="tabindexs">删除</span>	
								</el-popover>
								</td>
							</tr>
							<tr v-if="!isdisable">
								<td colspan="6">
									<span class="addbtn" @click="addlowpolic(data)">添加子机构政策</span>
								</td>
								<td></td>
							</tr>
					</table>
				<el-dialog title="添加下游政策" :visible.sync="isshow" width="550px" :close-on-click-modal='false'>
				<div class="content">
					<el-form :model="json" :rules="ruless" ref="json" label-width="150px">
						
						<el-form-item label="子机构" label-width="150px" prop="targetId">
							<el-select v-if="json.extendType==1" no-data-text="无部门可选" class="inputs"  v-model="json.targetId" size="mini" placeholder="请选择子机构">
								<el-option v-for="item in organization" :label="item.organizationName" :key="item.organizationId" :value="item.organizationId"></el-option>
							</el-select>

							<el-select v-else class="inputs" no-data-text="无用户可选"  v-model="json.targetId" size="mini" placeholder="请选择对象">
								<el-option v-for="item in userlist" :label="item.name" :value="item.id" :key="item.id"></el-option>
							</el-select>
						</el-form-item>

						<el-form-item label="交强险设置:" label-width="150px">
							<div class="numcontent" :class="indexs==1?'actives':''">
								<span>
									佣金
								<input @focus="focusselect($event)" @change="clearNoNum_2($event,'lowerBrokerageTraffic',100)" class="numinp" v-model="json.lowerBrokerageTraffic" />
								<span class="Percentage_color"> {{data.brokerageBusinessType  | isPercentage}}</span> 
								</span>
								
								<span>
									奖励
								<input @focus="focusselect($event)" @change="clearNoNum_2($event,'lowerRewardTraffic',100)" class="numinp" v-model="json.lowerRewardTraffic" size="mini" />
								<span class="Percentage_color"> {{data.brokerageBusinessType  | isPercentage}}</span>
								</span>
								
							</div>
						</el-form-item>

						<el-form-item label="商业险设置:" label-width="150px">
							<div class="numcontent" :class="indexs_tow==2?'actives_tuo':''">
								<span>
									佣金
								<input @focus="focusselect($event)" @change="clearNoNum_2($event,'lowerBrokerageBusiness',100)" class="numinp" v-model="json.lowerBrokerageBusiness" size="mini" />
								<span class="Percentage_color"> {{data.brokerageBusinessType  | isPercentage}}</span> 
								</span>
								
								<span>
									奖励
								<input @focus="focusselect($event)" @change="clearNoNum_2($event,'lowerRewardBusiness',100)" class="numinp" v-model="json.lowerRewardBusiness" size="mini" />
								<span class="Percentage_color"> {{data.brokerageBusinessType  | isPercentage}}</span>
								</span>
								
							</div>
						</el-form-item>
						
						<el-form-item label="车船税设置:" label-width="150px">
							<div class="numcontent">
								<span>
									佣金
								<input @focus="focusselect($event)" @change="clearNoNum_2($event,'lowerBrokerageVehicleTax',100)" class="numinp" v-model="json.lowerBrokerageVehicleTax" size="mini" />
								<span class="Percentage_color"> {{data.brokerageBusinessType  | isPercentage}}</span> 
								</span>
							</div>
						</el-form-item>
						
						<el-form-item class="btns">

							<el-button type="primary" @click.stop="submits('json')" :loading="loading2">确 定</el-button>
						</el-form-item>

					</el-form>
				</div>
			</el-dialog>
		
				<el-dialog title="编辑下游政策" :visible.sync="editisshow" width="550px" :close-on-click-modal='false' @close="quxiao">
				<div class="content">
					<el-form :model="copyjson" :rules="ruless" ref="copyjson" label-width="150px">
						
						<el-form-item label="子机构" label-width="150px" prop="targetId">
							<el-select v-if="json.extendType==1" no-data-text="无部门可选" class="inputs"  v-model="copyjson.targetId" size="mini" placeholder="请选择子机构">
								<el-option v-for="item in orgnewarr" :label="item.organizationName" :key="item.organizationId" :value="item.organizationId"></el-option>
							</el-select>

							<el-select v-else class="inputs" no-data-text="无用户可选"  v-model="copyjson.targetId" size="mini" placeholder="请选择对象">
								<el-option v-for="item in userlist" :label="item.name" :value="item.id" :key="item.id"></el-option>
							</el-select>
						</el-form-item>

						<el-form-item label="交强险设置:" label-width="150px">
							<div class="numcontent" :class="indexs==1?'actives':''">
								<span>
									佣金
								<input @focus="focusselect($event)" @change="clearNoNum_2($event,'lowerBrokerageTraffic',100)" class="numinp" v-model="copyjson.lowerBrokerageTraffic" />
								<span class="Percentage_color"> {{data.brokerageBusinessType  | isPercentage}}</span> 
								</span>
								
								<span>
									奖励
								<input @focus="focusselect($event)" @change="clearNoNum_2($event,'lowerRewardTraffic',100)" class="numinp" v-model="copyjson.lowerRewardTraffic" size="mini" />
								<span class="Percentage_color"> {{data.brokerageBusinessType  | isPercentage}}</span>
								</span>
								
							</div>
						</el-form-item>

						<el-form-item label="商业险设置:" label-width="150px">
							<div class="numcontent" :class="indexs_tow==2?'actives_tuo':''">
								<span>
									佣金
								<input @focus="focusselect($event)" @change="clearNoNum_2($event,'lowerBrokerageBusiness',100)" class="numinp" v-model="copyjson.lowerBrokerageBusiness" size="mini" />
								<span class="Percentage_color"> {{data.brokerageBusinessType  | isPercentage}}</span> 
								</span>
								
								<span>
									奖励
								<input @focus="focusselect($event)" @change="clearNoNum_2($event,'lowerRewardBusiness',100)" class="numinp" v-model="copyjson.lowerRewardBusiness" size="mini" />
								<span class="Percentage_color"> {{data.brokerageBusinessType  | isPercentage}}</span>
								</span>
								
							</div>
						</el-form-item>
						
						<el-form-item label="车船税设置:" label-width="150px">
							<div class="numcontent" :class="indexs_tow==2?'actives_tuo':''">
								<span>
									佣金
								<input @focus="focusselect($event)" @change="clearNoNum_2($event,'lowerBrokerageVehicleTax',100)" class="numinp" v-model="copyjson.lowerBrokerageVehicleTax" size="mini" />
								<span class="Percentage_color"> {{data.brokerageBusinessType  | isPercentage}}</span> 
								</span>
								

							</div>
						</el-form-item>
						<el-form-item class="btns">

							<el-button type="primary" @click.stop="editsubmits('copyjson')" :loading="loading2">确 定</el-button>
						</el-form-item>

					</el-form>
				</div>
			</el-dialog>
		
         
        
        </div>
        
        </div>
       
        
        </div>
         <div style="margin-bottom:72px;">
      	
      	</div>
       </div>
     
        <div class="bomfixed">
        	<div class="bomfixed_content">
        		<div class="bomfixed_left">
        			<el-form-item label-width="100px" label="政策描述" class="is-required" prop="remarks">
			          <el-input :disabled='isdisable' size="mini" v-model="data.remarks" placeholder="请填写政策描述"></el-input>
			        </el-form-item>
        		</div>
        			
		        <div class="bomfixed_right" v-if="stream =='1'">
		        	
		          <el-form-item class="center" v-if="!isdisable">
		            <el-button type="primary" size="mini" @click="onSubmit('data')" :loading="loadings">保存</el-button>
		            <el-button size="mini" @click="cancel">取消</el-button>
		          </el-form-item>
		          <el-form-item class="center" v-if="isdisable">
		            <el-button size="mini" @click="cancel">返回</el-button>
		          </el-form-item>
		        </div>
		        <div class="bomfixed_right" v-if="stream =='2'">
		        	<el-form-item class="center" v-if="!isdisable">
		            <el-button type="primary" size="mini" @click="onSubmitxia('data')" :loading="loadings">保存</el-button>
		            <el-button size="mini" @click="cancel">取消</el-button>
		          </el-form-item>
		          <el-form-item class="center">
		            <el-button size="mini" @click="cancel2">返回</el-button>
		          </el-form-item>
		        </div>
        	</div>
        </div>
      </el-form>

    </div>
  </div>
</template>

<script>
import Vue from "vue";
import minmax from "@/components/minmax";
import ztreeSelect from "@/components/z-select/index.vue";
import addModel from '@/components/addModel/addModel'
import api from '@/api/api.js'
export default {
  components: {
    minmax,
    ztreeSelect,
    addModel
  },
  data() {
    var domax = (rule, value, callback) => {
      let yj = this.data.upperBrokerageTraffic;
      let jl = this.data.upperRewardTraffic;
      if (isNaN(value)) {
        return callback(new Error("请填写交强险"));
      }

      let type = this.data.brokerageBusinessType;

      if (type == "0") {
        if (value > 100) {
          callback(new Error("佣金+奖励比例不能大于100"));
        } else {
          callback();
        }
      } else {
        callback();
      }
    };
    var symax = (rule, value, callback) => {
      let yj = this.data.upperBrokerageBusiness;
      let jl = this.data.upperRewardBusiness;
      if (isNaN(value)) {
        return callback(new Error("请填写商业险"));
      }

      let type = this.data.brokerageBusinessType;

      if (type == "0") {
        if (value > 100) {
          callback(new Error("佣金+奖励比例不能大于100"));
        } else {
          callback();
        }
      } else {
        callback();
      }
    };
    return {
    		lists:["第一个","第二个"],
    	orgnewarr:[],
    	textdires:"",
    	arrdefaults:[],
    	 childprops: {
        name: "displayName", //显示名字
        children: "childItem", //子级字段名
        lv: "level" //当前层级
      },
      waichildprops:{
      	name: "title", //显示名字
        children: "childs", //子级字段名
        lv: "id" //当前层级
      },
      noweditindex:null,
      treedata:[],
      error1: false,
      error2: false,
      error3: false,
      error4: false,
      batchId: "",
      insuranceId: "",
      policyItemId: '',
      errors: [],
      error: false,
      types: [],
      copyjson:{},
      form: {
        type: []
      },
      data: {
        upperPremiumType: "1",
        brokerageBusinessType: "0",
        chargeType: "0",
        upperBrokerageBusiness: "0", //上游商业险佣金比例
        upperRewardBusiness: "0", //上游商业险奖励比例
        upperBrokerageTraffic: "0", //上游交强险佣金比例
        upperRewardTraffic: "0", //上游交强险奖励比例
        upperBrokerageVehicleTax:"0",//上游车船税
        upperPremiumType:"1",
        lowerBrokerageBusiness:"0",
        lowerRewardBusiness:"0",
        lowerBrokerageTraffic:"0",
        lowerRewardTraffic:"0",
        lowerBrokerageVehicleTax:"0",
        lowerRewardVehicleTax:'0',
        extends:[]
      },
      
      filters: [],
      temarr: [],
      policyFilter: [],
      allhide1:false,
      allhide2:false,
      newArr: [],
      regions: [],
      loading: false,
      loadings:false,
      text: "到",
      bdqcheck: [],
      qtcheck: [],
      benshengHidden: false,
      bslist: [],
      checkedBs: [],
      bscheckAll: false,
      bscheck: [],
      isIndeterminate: false,
      waishengHidden: false,
      wslist: [],
      checkedWs: [],
      wscheckAll: false,
      wscheck: [],
      wsisIndeterminate: false,
      wsselect: "",
      wsarr: [],
      maxnum: 100,

      errorArr: [],
      	ruless: {
					extendType: [{
						required: true,
						message: '请选择对象类型',
						trigger: 'change'
					}],
					targetId: [{
						required: true,
						message: '请选择子机构',
						trigger: 'change'
					}],
					premiumType: [{
						required: true,
						message: '请选择保费类型',
						trigger: 'change'
					}],
					brokerageBusinessType: [{
						required: true,
						message: '请选择返佣类型',
						trigger: 'change'
					}],
					chargeType: [{
						required: true,
						message: '请选择是否扣点',
						trigger: 'change'
					}]

				},
      rules: {
        remarks: [
          { required: true, message: "请填写政策描述", trigger: "change"},
            { min: 0, max: 50, message: '长度在 0 到 50 个字符', trigger: 'change' }
        ],
        yongjin: [{ validator: domax, required: true, trigger: "blur" }],
        shangye: [{ validator: symax, required: true, trigger: "blur" }],
        chechuan: [{ validator: symax, required: true, trigger: "blur" }]
      },
      isdisable: false,
      stream: "",
      Jurisdiction: "1",
      toExpand:false,
      Underwriting_toExpand:false,
      loading2:false,
      indexs: null,
      copydata:{
      	upperPremiumType: "1",
        brokerageBusinessType: "0",
        chargeType: "0",
        upperBrokerageBusiness: "0", //上游商业险佣金比例
        upperRewardBusiness: "0", //上游商业险奖励比例
        upperBrokerageTraffic: "0", //上游交强险佣金比例
        upperRewardTraffic: "0", //上游交强险奖励比例
        
        upperPremiumType:"1",
        lowerBrokerageBusiness:"0",
        lowerRewardBusiness:"0",
        lowerBrokerageTraffic:"0",
        lowerRewardTraffic:"0",
        lowerBrokerageVehicleTax:"0",
        lowerRewardVehicleTax:'0',
        extends:[]
      },
				indexs_tow: null,
				organization:[],
				copyorganization:[],
				cossorganization:[],
      	cities:[
											{
												label:1,
												name:"本地区（工号所属地区）"
											},
											{
												label:2,
												name:"本省其他地区"
											},
											{
												label:3,
												name:"外省其他地区"
											},
											{
												label:4,
												name:"未知区域（适用于未上牌车辆）"
											},
										],
										checkboxGroup1:[],
										wsselect_add:"",
										checkedWs_add:[],
										namearr:[],
										insurance_model:[],
										no_insurance_model:[],
										now_checkedBs:[],
										isshow:false,
										editisshow:false,
											json: {
									policyItemId: "", //政策id
									extendType: "1", //对象类型,
									targetId: '', //对象
									lowerBrokerageTraffic: "0", //交强-佣金
									lowerRewardTraffic: "0", //较强——奖励
									lowerBrokerageBusiness: "0", //商业-佣金
									lowerRewardBusiness: "0", //商业——奖励
									lowerBrokerageVehicleTax: "0", //下游车船税佣金比例
									//	remarks: "" //备注
									
				
								},
    };
  },
  beforeRouteEnter(to, from, next){
  	
  	
  	console.log(to)
  	console.log(from)
  	console.log('from---------------------')
  	if(to.query.stream==1){
  		if(to.query.policyId&&!to.query.iscopy){
				to.meta.title="上游政策编辑"
			}else if(to.query.policyId&&to.query.iscopy){
				to.meta.title="上游政策复制"
			}else{
				to.meta.title="上游政策新建"
			}
  	}else{
  		if(to.query.policyId&&!to.query.iscopy){
				to.meta.title="下游政策编辑"
			}else if(to.query.policyId&&to.query.iscopy){
				to.meta.title="下游政策复制"
			}else{
				// console.log("孔孔孔孔孔孔孔孔")
				console.log(to)
				console.log(from)
				// to.path = '/policy/downstream/list/policyupnewdd'
				to.meta.title="下游政策新建"
			}
  	}
  	
  	
  	
  	next()
  },
  filters: {
    dayu(val) {
      let ind = val.indexOf("-");
      let min = val.substring(0, ind);
      if (val) {
        return min;
      }
    },
    isPercentage(val) {
				if(val == 0) {
					return "%"
				} else {
					return "元"
				}
			},
    xiaoyu(val) {
      let ind = val.indexOf("-");
      let max = val.substring(ind + 1);
      if (val) {
        return max;
      }
    },
    nametext(val){
    	if(val.length==0){
    		return "暂无数据"
    	}else{
    		if(val instanceof Array==true){
    			return val.join(",")
    		}
    		
    	}
    }
  },
  mounted() {
  	var that=this
  	setTimeout(function(){
  		console.log(11111111111111111)
  		//tabindexs
  		if(that.$refs.tabindexs){
  			that.$refs.tabindexs.map((val,index)=>{
  				that.$refs.tabindexs[index].setAttribute("tabindex","-1")
  			})
  		}
  		if(that.$refs.tabindexchild){
  			that.$refs.tabindexchild.map((val,index)=>{
  				that.$refs.tabindexchild[index].setAttribute("tabindex","-1")
  			})
  		}
  	},1000)
  	//	this.gettree()
    let querys = this.$route.query;
    this.insuranceId = querys.insuranceId;
    this.batchId = querys.batchId;
    this.policyItemId = querys.policyId;
    let status = querys.status;
    let stream = querys.stream; //1是上游 2是下游
    this.Jurisdiction = querys.Jurisdiction;
    this.stream = stream;
    console.warn(1111111);
		this.getbensheng()
		this.gethomes(this.policyItemId)
		this.getwaisheng()
    // this.status = status
    // if (stream == "2") {
    //   this.isdisable = false; //注意改这里
    // } 
      if (typeof status == "undefined" || status == "0" || status == "5") {//status为0 或者5或者没有值的时候可编辑
        this.isdisable = false;
      } else {
        this.isdisable = true; //注意改这里
      }
    
    this.loadUnits(querys.insuranceId, querys.batchId);
    if (stream == "1") {
      //上游
      if (querys.policyId) {
        this.editPolicy(querys.policyId);
      }
    } else if (stream == "2") {
      //下游
      if (querys.policyId) {
        this.editDownPolicy(querys.policyId);
      }
    }
  },
  computed: {
    yongjin() {
      let yj = this.data.upperBrokerageTraffic;
      let jl = this.data.upperRewardTraffic;
     
      let yongjin = Number(yj) + Number(jl);
      console.warn(yongjin);
      if (!isNaN(yongjin)) {
        this.data.yongjin = yongjin;
      }
    },
    shangye() {
      let yj = this.data.upperBrokerageBusiness;
      let jl = this.data.upperRewardBusiness;
      let shangye = Number(yj) + Number(jl);
      console.warn(shangye);
      if (!isNaN(shangye)) {
        this.data.shangye = shangye;
      }
    },
    chechuan() {
      let yj = this.data.upperBrokerageVehicleTax;
     
      let chechuan = Number(yj)
      console.warn(chechuan);
      if (!isNaN(chechuan)) {
        this.data.chechuan = chechuan;
      }
    }
  },
  methods: {
  	addmodel(val,e){
  		
  		let iscun=false
  		this.policyFilter[e].addsvalue.map((item)=>{
  			if(val==item){
  				   this.$message({
		          showClose: true,
		          message: '数据不能重复',
		          type: 'warning'
		        });
  				iscun=true
  			}
  		})
				if(iscun){
					return false
				}
					this.policyFilter[e].addsvalue.push(val)
				  let filters = this.filters;
		      filters[e].conditionValue = this.policyFilter[e].addsvalue.join(",");
		      this.filters = filters;
		      console.log()
			},
			removes(val,e){
					this.$confirm("确认删除吗", "提示", {
						confirmButtonText: "确定",
						cancelButtonText: "取消",
						closeOnClickModal: false
						// type: 'warning'
					}).then(() => {
						this.policyFilter[e].addsvalue.splice(val,1)
						
						let filters = this.filters;
		     	 	filters[e].conditionValue = this.policyFilter[e].addsvalue.join(",");
		     	 	this.filters = filters;
					});
				
			},
		 tabChange(){
			 	var that=this
				 setTimeout(function(){
					console.log(11111111111111111)
					//tabindexs
						console.log(that.$refs)
					console.log(that.$refs.tabindexchild)
					if(that.$refs.tabindexs){
						that.$refs.tabindexs.map((val,index)=>{
							that.$refs.tabindexs[index].setAttribute("tabindex","-1")
						})
					}
					if(that.$refs.tabindexchild){
						that.$refs.tabindexchild.map((val,index)=>{
							that.$refs.tabindexchild[index].setAttribute("tabindex","-1")
						})
					}
				},1000)
		 },
  	 focusselect(e) {
  	 	console.log(e)
      e.currentTarget.select();
    },
  	  deletefalse(val){
				this.$refs[val][0].doClose()
		    	
		    },
		    deletepolicy(val,e,refss) {
				console.log(val)
				
				
				this.data.extends.splice(e,1)
				this.copydata.extends.splice(e,1)
				let arr=val.targetId.split(",")
				this.copyorganization.map(val=>{
					arr.map(item=>{
						if(item==val.organizationId){
							this.organization.push(val)
						}
					})
				})
				
				//this.copydata.extends.splice(e,1)
//				let params = {
//					//policyBatchType: 1,
//					policyId: this.policyItemId,
//					policyItemRatesID:val.policyItemRateId
//					//policyItemRatesID: val.policyItemRateId,
//				}
//				this.post(params, "services/app/policy/DeleteExtendPolicy").then(res => {
//					console.log(res)
//					if(res.success) {
//						this.$notify({
//							title: '删除成功',
//							message: '您已成功删除一条政策',
//							type: 'success',
//							customClass: "el-notification-success"
//						});
//						this.$refs[refss][0].doClose()
//						this.editDownPolicy(this.policyItemId);
//					} else {
//						this.$notify.error({
//							title: '错误',
//							message: res.error.message
//						});
//
//					}
//				})
			},
  	clearNoNum_2(obj, name, maxnum) {
		    	   if(name) {
			        this.json[name] = this.api.clearNoNum_target(obj,maxnum,this.data.brokerageBusinessType)
			      }
		    
		    },
		    //增加
		    addusers(){
		    	
		    },
		    //去重
		    deleterepeat(crr,brr){
		    	
		    	let strs=JSON.stringify(this.organization)
		    	let arrs=JSON.parse(strs)
		    	this.organization.map((val,index)=>{
						//drr.push(val)
						
									//brr.map(item=>{
										if(brr==val.organizationId){
											crr.push(val.organizationName)
											this.organization.splice(index,1)
										//	drr.splice(index,1)
											//return this.deleterepeat(crr,brr)
										}
										
								//	})
							})
		    	
		    	console.log('----------------------------')
		    	console.log(this.organization)
		    	return crr
		    },
		    deleterepeatNew(crr,brr){
		    	console.log(brr)
		    	console.log("去重11111111111")
		    	console.log(this.orgnewarr)
		    	this.orgnewarr.map((val,index)=>{
		    		
								//	brr.map(item=>{
										if(brr==val.organizationId){
											crr.push(val.organizationName)
											this.orgnewarr.splice(index,1)
									//		return this.deleterepeatNew(crr,brr)
										}
										
								//	})
							})
		    	return crr
		    },
  	submits(formName) {
				let a1 = parseFloat(this.json.lowerBrokerageTraffic)
				let a2 = parseFloat(this.json.lowerRewardTraffic)
				let b1 = parseFloat(this.json.lowerBrokerageBusiness)
				let b2 = parseFloat(this.json.lowerRewardBusiness)
				
				this.$refs[formName].validate((valid) => {
					if(valid) {
						if(this.data.brokerageBusinessType==0){
						if(a1 + a2 > 100 && b1 + b2 > 100) {
							this.indexs_tow = 2
							this.indexs = 1
							this.$message.error("请正确输入");

						} else if(a1 + a2 > 100 || b1 + b2 > 100) {
							if(a1 + a2 > 100) {
								this.indexs = 1
								this.indexs_tow = null
								this.$message.error("请正确输入");

							} else {
								this.indexs_tow = 2
								this.indexs = null
								this.$message.error("请正确输入");

							}

						} else {
							this.indexs_tow = null
							this.indexs = null
							console.log(1111111111111)
							console.log(this.json)
							console.log(this.data)
							let brr=this.json.targetId
						//	this.json.targetId = this.json.targetId.join(",")
							let arr = [];
							arr.push(this.json);
							let params = {
								"extends": arr
							}
							let crr=[]
							
							this.deleterepeat(crr,brr)
							this.json.describe=crr
							this.json.isbackshow=false
		          this.json.isfront=false
							this.json.issecon=false
							this.json.isthree=false
							this.json.change1=false
							this.json.change2=false
							this.json.change3=false
							this.json.change4=false
							this.json.change5=false
							let str=JSON.stringify(this.json)
							this.data.extends.push(JSON.parse(str))
							this.copydata.extends.push(JSON.parse(str))
							console.log(this.data.extends)
							console.log(this.copydata.extends)
							this.$notify({
									title: "添加成功",
									message: "您已成功添加",
									type: "success",
									customClass: "el-notification-success"
								});
							this.isshow = false;
								this.tabChange();
						}
					}else{
						
					//	this.json.targetId = this.json.targetId.join(",")
							let arr = [];
							arr.push(this.json);
							let params = {
								"extends": arr
							}
							let crr=[];
							// let brr=this.json.targetId.split(',')
							let brr=this.json.targetId
							this.organization.map((val,index)=>{
								//	brr.map(item=>{
										if(brr==val.organizationId){
											crr.push(val.organizationName)
											this.organization.splice(index,1)
										}
										
									//})
							})
							this.json.describe=crr
							this.json.isbackshow=false
		          this.json.isfront=false
							this.json.issecon=false
								this.json.isthree=false
							
							this.json.change1=false
							this.json.change2=false
							this.json.change3=false
							this.json.change4=false
								this.json.change5=false
								this.$notify({
									title: "添加成功",
									message: "您已成功添加",
									type: "success",
									customClass: "el-notification-success"
								});
							let str=JSON.stringify(this.json)
							this.data.extends.push(JSON.parse(str))
							this.copydata.extends.push(JSON.parse(str))
							this.isshow = false;
								this.tabChange();
					}
						

					} else {
						console.log('error submit!!');
						return false;
					}
				});
			},
			quxiao(){
//			let str1=JSON.stringify(this.cossorganization)
//			this.orgnewarr=JSON.parse(str1)
			},
  	//添加下游政策 编辑按钮
  	editaddlowpolicPPPPPPP(val,index){
  		console.log(val)
  		console.log("kaisjhi")
  		console.log(this.copyorganization)
  		console.log(this.organization)
  		this.noweditindex=index
    		//let str1=JSON.stringify(this.organization)
    		 //this.cossorganization=JSON.parse(str1)
  		//organization
  		
				this.editisshow = true;
				let arr=val.targetId.split(",")
//						this.copyorganization.map(obj=>{
//							arr.map(item=>{
//								if(item==obj.organizationId){
//									this.organization.push(obj)
//								}
//								
//							})
//						})
				let str=JSON.stringify(val)
				this.copyjson=JSON.parse(str)
				for(var i=0;i<arr.length;i++){
					arr[i]=parseFloat(arr[i])
				}
					
				Vue.set(this.copyjson,"targetId",arr)
				console.log("jiedhu")
				console.log(this.organization)
			
				//this.copyjson.targetId=arr
  	},
  	editaddlowpolic(val,index){
				this.noweditindex=index; //下标，用于替换数组的下标
				let arr= val.targetId;
					let newarr=JSON.stringify(this.organization);
					let orgarr = JSON.parse(newarr); //数组互转不关联方法
					console.log(this.organization)
					this.copyorganization.map(obj=>{ //遍历追加
						//arr.map(item=>{
								if(obj.organizationId ==arr){
				  			 	  orgarr.push(obj)
				  			 }
					//	})
					})
				this.orgnewarr = orgarr //下拉数组数据
				let str=JSON.stringify(val)
				this.copyjson=JSON.parse(str)
				// for(var i=0;i<arr.length;i++){
				// 	arr[i]=parseFloat(arr[i])
				// }
				Vue.set(this.copyjson,"targetId",parseFloat(arr)) //当前选中
				this.editisshow = true;
  		
  	},
  	//确定按钮
  	editsubmits(formName) {
  		console.log("kaishi")
  		console.log(this.organization)
				let a1 = parseFloat(this.json.lowerBrokerageTraffic)
				let a2 = parseFloat(this.json.lowerRewardTraffic)
				let b1 = parseFloat(this.json.lowerBrokerageBusiness)
				let b2 = parseFloat(this.json.lowerRewardBusiness)
				
				this.$refs[formName].validate((valid) => {
					if(valid) {
						if(this.data.brokerageBusinessType==0){
						if(a1 + a2 > 100 && b1 + b2 > 100) {
							this.indexs_tow = 2
							this.indexs = 1
							this.$message.error("请正确输入");

						} else if(a1 + a2 > 100 || b1 + b2 > 100) {
							if(a1 + a2 > 100) {
								this.indexs = 1
								this.indexs_tow = null
								this.$message.error("请正确输入");

							} else {
								this.indexs_tow = 2
								this.indexs = null
								this.$message.error("请正确输入");

							}

						} else {
							this.indexs_tow = null
							this.indexs = null

							let brr=this.copyjson.targetId
							let crr=[]
							this.deleterepeatNew(crr,brr)
							this.copyjson.describe=crr
							//this.copyjson.targetId = this.copyjson.targetId.join(",")
							Vue.set(this.data.extends,this.noweditindex,this.copyjson)
							Vue.set(this.copydata.extends,this.noweditindex,this.copyjson)
							this.organization = this.orgnewarr;
							this.editisshow = false
						}
					}else{
						let brr=this.copyjson.targetId
							let crr=[]
							this.deleterepeatNew(crr,brr)
							this.copyjson.describe=crr
							//this.copyjson.targetId = this.copyjson.targetId.join(",")
							Vue.set(this.data.extends,this.noweditindex,this.copyjson)
							Vue.set(this.copydata.extends,this.noweditindex,this.copyjson)
							this.organization = this.orgnewarr;
							this.editisshow = false
							
					}
						

					} else {
						console.log('error submit!!');
						return false;
					}
				});
			},
			addlowpolic(val) {
				console.log(2222222222)
				console.log(val)
				let arr = []
				Vue.set(this.json, "targetId", arr)
				this.isshow = true;
				Vue.set(this.json, "premiumType", val.upperPremiumType)  //				premiumType: "1", //保费类型
				console.log(this.Maidlist)
				Vue.set(this.json,"brokerageBusinessType",val.upperBrokerageBusinessType)
				Vue.set(this.json,"chargeType",val.upperChargeType)
				
				Vue.set(this.json, "policyItemId", this.policyItemId)
				Vue.set(this.json, "lowerBrokerageTraffic", 0)
				Vue.set(this.json, "lowerRewardTraffic", 0)
				Vue.set(this.json, "lowerBrokerageBusiness", 0)
				Vue.set(this.json, "lowerRewardBusiness", 0)
				Vue.set(this.json, "lowerBrokerageVehicleTax", 0)
			//	this.gethomes(this.policyItemId)
				//this.getuesr(val.policyId)
			},
			//获取组织
			gethomes(val) {
				//organization
				let params = {
					id:val
				}
				this.post(params, "services/app/policy/ChildOrganizations").then(res => {
					console.log(res)
					if(res.success) {
						console.log("zuzhi")
						console.log(res)
						this.organization = res.result.child
						this.copyorganization=res.result.all
					} else {
						this.$notify.error({
							title: '错误',
							message: res.error.message
						});

					}
				})
			},
  	getchange_extendnum(val,index,name,types){
  			let aa=this.api.clearNoNum_target(val,100,types)
				Vue.set(this.data.extends[index],name,aa)
				Vue.set(this.copydata.extends[index],name,aa)
				Vue.set(this.data.extends[index],'isbackshow',true)
				let a1=parseFloat(this.data.extends[index].lowerBrokerageTraffic);
				let a2=parseFloat(this.data.extends[index].lowerRewardTraffic);
				let a3=parseFloat(this.data.extends[index].lowerBrokerageBusiness);
				let a4=parseFloat(this.data.extends[index].lowerRewardBusiness);
				let a5=parseFloat(this.data.extends[index].lowerBrokerageVehicleTax);
				if(name=="lowerBrokerageTraffic"){
					Vue.set(this.data.extends[index],'change1',true)
				}
				if(name=="lowerRewardTraffic"){
					Vue.set(this.data.extends[index],'change2',true)
				}
				if(name=="lowerBrokerageBusiness"){
					Vue.set(this.data.extends[index],'change3',true)
				}
				if(name=="lowerRewardBusiness"){
					Vue.set(this.data.extends[index],'change4',true)
				}
				if(name=="lowerBrokerageVehicleTax"){
					Vue.set(this.data.extends[index],'change5',true)
				}
				if(types==0){
					if(a1+a2>100){
						
						Vue.set(this.data.extends[index],'isfront',true)
					}else{
						Vue.set(this.data.extends[index],'isfront',false)
					}
					if(a3+a4>100){
						
						Vue.set(this.data.extends[index],'issecon',true)
					}else{
						Vue.set(this.data.extends[index],'issecon',false)
					}
					if(a5>100){
						
						Vue.set(this.data.extends[index],'isthree',true)
					}else{
						Vue.set(this.data.extends[index],'isthree',false)
					}
					
				}else{
					Vue.set(this.data.extends[index],'isfront',false)
					Vue.set(this.data.extends[index],'issecon',false)
					Vue.set(this.data.extends[index],'isthree',false)
				}
				
  	},
		getchange_num(val,name,types){
			let aa=this.api.clearNoNum_target(val,100,types)
			Vue.set(this.data,name,aa)
			Vue.set(this.data,'isbackshow',true)
				let a1=parseFloat(this.data.lowerBrokerageTraffic);
				let a2=parseFloat(this.data.lowerRewardTraffic);
				let a3=parseFloat(this.data.lowerBrokerageBusiness);
				let a4=parseFloat(this.data.lowerRewardBusiness);
				let a5=parseFloat(this.data.lowerBrokerageVehicleTax);
				if(name=="lowerBrokerageTraffic"){
					Vue.set(this.data,'change1',true)
				}
				if(name=="lowerRewardTraffic"){
					Vue.set(this.data,'change2',true)
				}
				if(name=="lowerBrokerageBusiness"){
					Vue.set(this.data,'change3',true)
				}
				if(name=="lowerRewardBusiness"){
					Vue.set(this.data,'change4',true)
				}
					if(name=="lowerBrokerageVehicleTax"){
					Vue.set(this.data,'change5',true)
				}
				if(types==0){
					if(a1+a2>100){
					
						Vue.set(this.data,'isfront',true)
					}
					if(a1+a2<=100){
						Vue.set(this.data,'isfront',false)
					}
					if(a3+a4>100){
						
						Vue.set(this.data,'issecon',true)
					}
					if(a3+a4<=100){
						Vue.set(this.data,'issecon',false)
					}
					if(a5>100){
						Vue.set(this.data,'isthree',true)
					}
					if(a5<=100){
						Vue.set(this.data,'isthree',false)
					}
					
				}else{
					Vue.set(this.data,'isfront',false)
					Vue.set(this.data,'issecon',false)
					Vue.set(this.data,'isthree',false)
					
				}
				
		},
  	//baohan选中
  	getinsurance_model(val,index){
  	
  		let filters = this.filters;
  		filters[index].conditionValue=val.join(",");
  	},
  	no_getinsurance_model(val,index){
  		
  		let filters = this.filters;
  		filters[index].conditionValue=val.join(",");
  	},
  	//返回
  	go_backs(){
  		this.$router.go(-1)
  	},
  	//书改变
  	selectChange_tree(val,index,obj){
  		let arr=[]
  		this.namearr=arr
  	
  		this.recursion(val,obj)
  		
  		
  		
  		let filters = this.filters;
  		filters[index].conditionValue=val.join(",");
  	},
  	 recursion(val,obj){
			for(let i=0;i<obj.length;i++){
					for(let k=0;k<val.length;k++){
						if(val[k]==obj[i].id){
							this.namearr.push(obj[i].displayName)
						}
					}
					if(obj[i].childItem){
						this.recursion(val,obj[i].childItem)
					}
			}
			
		},
//	//获取数数据
//	gettree(){
//		let params = {}
//    this.post(params, "services/app/common/GetCurrentOrganizationUnits").then(rs => {
//      if (rs.success) {
//      	console.log("shu11111111111111111111111111")
//      	console.log(rs)
//        this.treedata.push(rs.result)
//      }
//    });
//	},
  	//获取选中数据
  	getstr(){
  		let str=""
  		let arrJson=JSON.stringify(this.checkboxGroup1)
  		let arr=JSON.parse(arrJson)
  		for(let i=0;i<arr.length;i++){
				console.log("招啊招啊")
				console.log(this.checkedWs.length)
  			if(arr[i]==2){
  				if(this.checkedBs.length !== 0){
						console.log("大萨达撒")
  					if(this.checkedBs instanceof Array==true){
							// let ins = this.checkedBs.indexOf('quanbu')
							// if(ins !== -1){
							// 	this.checkedBs.splice(ins,1)
							// }
							
							let label2=2+":"+this.checkedBs.join("-")
							// let str = label2.replace("-quanbu","")
  						Vue.set(arr,i,label2)
							console.log(str)

  					}
  					
  				}
  			}
  			if(arr[i]==3){
  				if(this.checkedWs.length!==0){
  					if(this.checkedWs instanceof Array==true){
							console.log(this.checkedWs)
							console.log("is waisheng 外省")
							let label3=3+":"+this.checkedWs.join("-")
							console.log("对对对对对对多")
								console.log(label3)
							// let str = label3.replace("-quanbu","")
  						Vue.set(arr,i,label3)
  					}
  					
  				}
  			}
  		}
  		str=arr.join(",")
  		return str	
  	},
  	//地区多选
  	pickcheckbox(val,index){
			const me = this;
  		let str=this.getstr()
			// console.log(val)
			// let bslist = this.bslist;
			// function bsall(){
			// 	let arr = []
			// 	bslist.map(function(obj){
			// 		arr.push(obj.id)
			// 	})
			// 	return arr;
			// }
		
			// console.log(bsall())
			// val.map(function(item){
			// 	if(item == 2){
			// 		me.checkedBs = bsall();
			// 	}else if(item == 3){
			// 	//	me.checkedWs = me.wslist;
			// 	}else{
			// 		me.checkedBs = []
			// 	}
				
			// })
			
			console.log("地区选择的时候")
       let filters = this.filters;
  		filters[index].conditionValue=str;
		},
		//投放区域
		picktf(event,val){
			console.log(event)
			console.log(val)
			const me = this;
			let bslist = this.bslist;
			function bsall(){
				let arr = []
				bslist.map(function(obj){
					arr.push(obj.id)
				})
				return arr;
			}
			
			function itswsall(){
				
				let itsall =[]
				function wsall(data){
					
				data.map(function(elem){
						itsall.push(elem.id)
						if(elem.childs instanceof Array){
								wsall(elem.childs)
						}
					})
				}
				wsall(me.wslist)
				return itsall
			}
			console.log(itswsall())
			if(val == 2){
				if(event){
					me.checkedBs = bsall();
				}else{
					me.checkedBs = [];
				}
				
			}
			if(val == 3){
				if(event){
						me.checkedWs =itswsall();
				}else{
					me.checkedWs =[]
				}
			
			}
		},
  	//扩展信息
  	selectChangeextends(val,index){
  		 let filters = this.filters;
     	 filters[index].extendInfo = val;
  	},
  	//zhankai
  	isExpand(){
  		this.toExpand=!this.toExpand
  		if(this.toExpand==true){
			this.allhide1=false
  			for(var i=0;i<this.policyFilter.length;i++){
  				if(this.policyFilter[i].conditionType==1){
  					this.policyFilter[i].add_isShow=true
  				}
  			}
  			
  		}else{
  			this.allhide1=true
for(var i=0;i<this.policyFilter.length;i++){
  				if(this.policyFilter[i].conditionType==1){
  					//this.policyFilter[i].add_isShow=this.policyFilter[i].isShow
  					Vue.set(this.policyFilter[i],"add_isShow",this.policyFilter[i].isShow)
  					if(this.policyFilter[i].isShow==true){
  						this.allhide1=false
  					}
  				}
  			}
				
  		}
  		
  	},
  	//承保条件收起
  	Underwriting_isExpand(){
  	
  		this.Underwriting_toExpand=!this.Underwriting_toExpand
  		var that=this
  				if(this.Underwriting_toExpand==true){
  						this.allhide2=false
	  			this.policyFilter.map(function(item,index){
	  				if(item.conditionType==2){
	  					item.add_isShow=true
	  				}
		  		})
  		}else{
  			var that=this
  			console.log(this.policyFilter)
  				this.allhide2=true
  				this.policyFilter.map(function(item){
	  				if(item.conditionType==2){
	  					//item.add_isShow=item.isShow
	  					Vue.set(item,"add_isShow",item.isShow)
	  					if(item.add_isShow==true){
	  						that.allhide2=false
	  					}
	  				}
		  		})
  		}
  		
  	},
    //上游编辑
    editPolicy(id) {
      let params = {
        id: id
      };
      this.post(params, "services/app/policy/GetUpperPolicyDetail").then(rs => {
      	

        if (rs.success) {
        	console.log("shujusss")
        	console.log(rs)
          this.data = rs.result;
          
        }
      });
    },
    //下游编辑
    editDownPolicy(id) {
      let params = {
        id: id
      };
      this.post(params, "services/app/policy/GetLowerPolicyDetail").then(rs => {
     
			
        if (rs.success) {
        	  console.log("shujhussssss")
        	   console.log(rs)
          this.data = rs.result;
//        let str=JSON.stringify(this.data)
//        this.copydata=JSON.parse(str)
         
          
          this.data.isbackshow=false
          this.data.isfront=false
					this.data.issecon=false
					this.data.isthree=false
					
					this.data.change1=false
					this.data.change2=false
					this.data.change3=false
					this.data.change4=false
						this.data.change5=false
					//extends
					this.data.extends.map(item=>{
						item.isbackshow=false
	          item.isfront=false
						item.issecon=false
						item.isthree=false
						item.change1=false
						item.change2=false
						item.change3=false
						item.change4=false
							item.change5=false
					})
				
					if(this.data.extends.length>0){
							this.data.extends.map(val=>{
							val.extendType=val.extendTypes
						})
					}
					console.log(11111111111111111111111)
					console.log(this.data)
					
					 let str=JSON.stringify(this.data)
          this.copydata=JSON.parse(str)
           if( this.copydata.extends.length>0){
          	this.copydata.extends.map(val=>{
	          	val.extendType=val.extendTypes
	          })
          }
        }
      });
    },
    clearNoNum(obj, name, maxnum) {
    	
    	   if(name) {
	        this.data[name] =  api.clearNoNum(obj,maxnum,this.data.brokerageBusinessType)
	      }
    
    },
    //保费类型
    premiumchange(val) {
     console.log(val)
      Vue.set(this.data,"upperPremiumType",val);
    },
    //返佣类型
    Maidchange(val) {
      Vue.set(this.data, "brokerageBusinessType", val);
     
    },
    //是否扣点
    Pointschange(val) {
      Vue.set(this.data, "chargeType", val);
    },
    getTotal(event, index) {
      
      let filters = this.filters;
      filters[index].conditionValue = event;
    },
    getval(event, index){
    	
      let filters = this.filters;
      filters[index].conditionValue = event.target._value;
    },
    getError(val, id) {
     
      let errorArr = this.errorArr;
      if (errorArr.length == 0) {
        errorArr.push({ id: id, error: val });
      } else {
        let have = false;
        for (let i = 0; i < errorArr.length; i++) {
          const element = errorArr[i];
          if (element.id == id) {
            element.error = val;
            have = true;
          }
        }
        if (!have) {
          errorArr.push({ id: id, error: val });
        }
      }
     
    },
    iserror() {
      let errorArr = this.errorArr;
      let iserror;
      errorArr.map(item => {
        if (item.error) {
          iserror = true;
        }
      });
      return iserror;
    },
    bitian(num) {
      let data = this.data;

      let error1 = data.upperBrokerageTraffic;
      let error2 = data.upperRewardTraffic;
      let error3 = data.upperBrokerageBusiness;
      let error4 = data.upperRewardBusiness;
     
      if (num) {
        if ((num == "1" && typeof error1 == "undefined") || error1 == "") {
          this.error1 = true;
        } else {
          
          this.error1 = false;
        }
        if ((num == "2" && typeof error2 == "undefined") || error2 == "") {
          this.error2 = true;
        } else {
          this.error2 = false;
        }
        if ((num == "3" && typeof error3 == "undefined") || error3 == "") {
          this.error3 = true;
        } else {
          this.error3 = false;
        }
        if ((num == "4" && typeof error4 == "undefined") || error4 == "") {
          this.error4 = true;
        } else {
          this.error4 = false;
        }
        // let errors = 'error'+num
        // if(num =="1" ){

        // }
        // if(typeof(errors) == 'undefined'){
        //   this[errors] = true
        // }
      } else {
        if (typeof error1 == "undefined" || error1 == "") {
          this.error1 = true;
        }
        if (typeof error2 == "undefined" || error2 == "") {
          this.error2 = true;
        }
        if (typeof error3 == "undefined" || error3 == "") {
          this.error3 = true;
        }
        if (typeof error4 == "undefined" || error4 == "") {
          this.error4 = true;
        }
      }

      if (
        (typeof error1 !== "undefined" &&
          typeof error2 !== "undefined" &&
          typeof error3 !== "undefined" &&
          typeof error4 !== "undefined") ||
        (typeof error1 !== "" &&
          typeof error2 !== "" &&
          typeof error3 !== "" &&
          typeof error4 !== "")
      ) {
       
        return false;
      } else {
        
        return true;
      }
    },
    cancel() {
      this.$router.back(-1);
      // this.$router.push({
      //   name: "policyupper3c",
      //   query: {
      //     batchId: this.batchId,
      //     Jurisdiction :this.Jurisdiction
      //   }
      // });
    },
    cancel2() {
      this.$router.back(-1);
      // this.$router.push({
      //   name: "policylower3",
      //   query: {
      //     batchId: this.batchId,
      //     Jurisdiction :this.Jurisdiction
      //   }
      // });
    },
    //验证是否有大于100
    iscansub(){
    	var that=this
    	let aa=false
    	console.log(this.data.brokerageBusinessType)
    	console.log(this.copydata)
    	if(this.data.brokerageBusinessType==0){
    		let a1= parseFloat(this.data.lowerBrokerageBusiness) 
    		let a2=parseFloat(this.data.lowerRewardBusiness)
    		let a3=parseFloat(this.data.lowerBrokerageTraffic)
				let a4=parseFloat(this.data.lowerRewardTraffic)
				let a5=parseFloat(this.data.lowerBrokerageVehicleTax)
				console.log(a1,a2,a3,a4)
    		if(a1+a2>100){
    			Vue.set(this.data,'issecon',true)
    			//this.data=Object.assign({},this.data,{'isfront':true})
    			aa=true
    		}
    		if(a3+a4>100){
    			Vue.set(this.data,'isfront',true)
    			aa=true
    		}
    		if(a5>100){
    			Vue.set(this.data,'isthree',true)
    			aa=true
    		}
    		console.log(this.data)
    		let dd = []
    		this.copydata.extends.map((val,index)=>{
    			let b1=parseFloat(val.lowerBrokerageTraffic)
	    		let b2=parseFloat(val.lowerRewardTraffic)
	    		let b3=parseFloat(val.lowerBrokerageBusiness)
	    		let b4=parseFloat(val.lowerRewardBusiness)
	    		let b5=parseFloat(val.lowerBrokerageVehicleTax)
					dd.push(this.data.extends[index])
						console.log(b1,b2,b3,b4)
	    		if(b1+b2>100){
	    			dd[index].isfront= true;
	    			console.log(this.data.extends[index])
	    			aa=true
					}
	    		if(b3+b4>100){
	    			
	    			dd[index].issecon = true;
	    			console.log(22222)
	    			//this.data.extends[index]=Object.assign({},this.data.extends[index],{'issecon':true})
	    			aa=true
	    		}
	    		if(b5>100){
	    			
	    			dd[index].isthree = true;
	    	
	    			aa=true
	    		}
	    		
    		})
    		Vue.set(this.data,"extends" ,dd)
    	}
    	return aa
    },
	onSubmitxia(formName){
		console.log(this.copydata.extends)
		let _this = this;
		 this.$refs[formName].validate(valid => {
        if (valid) {
          //验证通过
          let iserror = this.iserror();
          //let bitian = this.bitian();
          let iserror2=this.iscansub()
          
          if (iserror || iserror2) {
            this.$message.error("请正确输入");
          } else {
          	this.loadings=true
            let data = this.data;
            
            let params = {};
            if (this.policyItemId&&!this.$route.query.iscopy) {
              //下游编辑
             
              console.log("edit")
							console.log(data)
							for(let i=0;i<this.filters.length;i++){
								if(this.filters[i].policyFilterId == 66 && !this.filters[i].extendInfo){
									this.filters[i].extendInfo = this.id66;
								}
								if(this.filters[i].policyFilterId == 68 && !this.filters[i].extendInfo){
									this.filters[i].extendInfo = this.id68;
								}
								if(this.filters[i].policyFilterId == 58 && !this.filters[i].extendInfo){
									this.filters[i].extendInfo = this.id58;
								}
							}
              params = {
                Id: this.policyItemId,
                BrokerageBusinessType: Number(data.brokerageBusinessType), //返佣的类型 0:百分比 1:元
                ChargeType: Number(data.chargeType), //政策类型返佣或扣点
                lowerPremiumType: Number(data.upperPremiumType), ///上游手续费保费类型，全保费和净保费
                lowerBrokerageBusiness: data.lowerBrokerageBusiness, //上游商业险佣金比例
                lowerRewardBusiness: data.lowerRewardBusiness, //上游商业险奖励比例
                lowerBrokerageTraffic: data.lowerBrokerageTraffic, //上游交强险佣金比例
                lowerRewardTraffic: data.lowerRewardTraffic, //上游交强险奖励比例
                lowerBrokerageVehicleTax: data.lowerBrokerageVehicleTax, //上游车船税佣金比例
                lowerRewardVehicleTax: data.upperRewardVehicleTax, //上游车船税奖励手续费
                remarks: data.remarks,
                Filters: this.filters,//lowerBrokerageVehicleTax 
                Extends:this.copydata.extends
              };
            	 console.log(params)
              this.post(params, "services/app/policy/UpdateLowerPolicy").then(
                rs => {
                  if (rs.success) {
                  	this.loadings=false
									this.$router.go(-1)
                  }else{
                  	this.loadings=false
	                  	this.$notify.error({
											title: '错误',
											message: rs.error.message
										});

                  }
                }
              );
            } else {
							//xia游新建
							// console.log(_this.filters);
              console.log(1234567891111111111)
              if(!_this.copydata.extends){
              	let arr=[]
              	Vue.set(_this.copydata,"extends",arr)
							}
							for(let i=0;i<_this.filters.length;i++){
								if(_this.filters[i].policyFilterId == 66 && !_this.filters[i].extendInfo){
									_this.filters[i].extendInfo = _this.id66;
								}
								if(_this.filters[i].policyFilterId == 68 && !_this.filters[i].extendInfo){
									_this.filters[i].extendInfo = _this.id68;
								}
								if(_this.filters[i].policyFilterId == 58 && !_this.filters[i].extendInfo){
									_this.filters[i].extendInfo = _this.id58;
								}
							}
              params = {
              	//brokerageBusinessType
                PolicyBatchId: this.batchId,
                BrokerageBusinessType: Number(data.brokerageBusinessType), //返佣的类型 0:百分比 1:元
                ChargeType: Number(data.chargeType), //政策类型返佣或扣点
                lowerPremiumType: Number(data.upperPremiumType), ///上游手续费保费类型，全保费和净保费
                lowerBrokerageBusiness: data.lowerBrokerageBusiness, //上游商业险佣金比例
                lowerRewardBusiness: data.lowerRewardBusiness, //上游商业险奖励比例
                lowerBrokerageTraffic: data.lowerBrokerageTraffic, //上游交强险佣金比例
                lowerRewardTraffic: data.lowerRewardTraffic, //上游交强险奖励比例
                lowerBrokerageVehicleTax: data.lowerBrokerageVehicleTax, //上游车船税佣金比例
                lowerRewardVehicleTax: data.upperRewardVehicleTax, //上游车船税奖励手续费
                remarks: data.remarks,
                Filters: this.filters,
               	Extends:this.copydata.extends
              };
              this.post(params,"services/app/policy/CreateNewLowerPolicy").then(rs => {
                if (rs.success) {
									this.$router.go(-1)
                }else{
                	if(rs.error.code==-1){
                		this.loadings=false
	                  	this.$notify.error({
											title: '错误',
											message: '同一批次中政策的描述信息不能重复'
										});
                	}else{
                		this.loadings=false
	                  	this.$notify.error({
											title: '错误',
											message: rs.error.message
										});
                	}
                  	

                  }
              });
            }
           
          }
        } else {
          
          return false;
        }
      });
	},
    onSubmit(formName) {
//  	this.filters.map((item)=>{
//  		if(item.policyFilterId==73){
//  			console.log(item)
//  		}
//  	})
//  	return false
      this.$refs[formName].validate(valid => {
        if (valid) {
          //验证通过
          let iserror = this.iserror();
          //let bitian = this.bitian();
          
          if (iserror) {
            this.$message.error("请正确输入");
          } else {
          	this.loadings=true
            let data = this.data;
            let params = {};
            data.upperBrokerageBusiness=data.upperBrokerageBusiness==""?0:data.upperBrokerageBusiness
            data.upperRewardBusiness=data.upperRewardBusiness==""?0:data.upperRewardBusiness
            data.upperBrokerageTraffic=data.upperBrokerageTraffic==""?0:data.upperBrokerageTraffic
            data.upperRewardTraffic=data.upperRewardTraffic==""?0:data.upperRewardTraffic
            if (this.policyItemId&&!this.$route.query.iscopy) {
              //上游编辑
              params = {
                Id: this.policyItemId,
                BrokerageBusinessType: Number(data.brokerageBusinessType), //返佣的类型 0:百分比 1:元
                ChargeType: Number(data.chargeType), //政策类型返佣或扣点
                upperPremiumType: Number(data.upperPremiumType), ///上游手续费保费类型，全保费和净保费
                UpperBrokerageBusiness: data.upperBrokerageBusiness, //上游商业险佣金比例
                UpperRewardBusiness: data.upperRewardBusiness, //上游商业险奖励比例
                UpperBrokerageTraffic: data.upperBrokerageTraffic, //上游交强险佣金比例
                UpperRewardTraffic: data.upperRewardTraffic, //上游交强险奖励比例
                UpperBrokerageVehicleTax: data.upperBrokerageVehicleTax, //上游车船税佣金比例
                UpperRewardVehicleTax: data.upperRewardVehicleTax, //上游车船税奖励手续费
                remarks: data.remarks,
                Filters: this.filters,
           
              };
             
              this.post(params, "services/app/policy/UpdateUpperPolicy").then(
                rs => {
                  
									
                  if (rs.success) {
                  	this.loadings=false
//                  this.$router.push({
//                    name: "policyupper3c",
//                    query: {
//                      batchId: this.batchId,
//                      Jurisdiction: this.Jurisdiction
//                    }
//                  });
									this.$router.go(-1)
                  }else{
                  	this.loadings=false
	                  	this.$notify.error({
											title: '错误',
											message: rs.error.message
										});

                  }
                }
              );
            } else {
              //上游新建
              params = {
                PolicyBatchId: this.batchId,
                BrokerageBusinessType: Number(data.brokerageBusinessType), //返佣的类型 0:百分比 1:元
                ChargeType: Number(data.chargeType), //政策类型返佣或扣点
                upperPremiumType: Number(data.upperPremiumType), ///上游手续费保费类型，全保费和净保费
                UpperBrokerageBusiness: data.upperBrokerageBusiness, //上游商业险佣金比例
                UpperRewardBusiness: data.upperRewardBusiness, //上游商业险奖励比例
                UpperBrokerageTraffic: data.upperBrokerageTraffic, //上游交强险佣金比例
                UpperRewardTraffic: data.upperRewardTraffic, //上游交强险奖励比例
                UpperBrokerageVehicleTax: data.upperBrokerageVehicleTax, //上游车船税佣金比例
                UpperRewardVehicleTax: data.upperRewardVehicleTax, //上游车船税奖励手续费
                remarks: data.remarks,
                Filters: this.filters
              };
              this.post(
                params,
                "services/app/policy/CreateNewUpperPolicy"
              ).then(rs => {
               

                if (rs.success) {
//                this.$router.push({
//                  name: "policyupper3c",
//                  query: {
//                    batchId: this.batchId,
//                    Jurisdiction: this.Jurisdiction
//                  }
//                });
									this.$router.go(-1)
                }else{
                  	this.loadings=false
	                  	this.$notify.error({
										title: '错误',
										message: rs.error.message
									});

                  }
              });
            }
           
          }
        } else {
          
          return false;
        }
      });
    },
    //上游新建

    //上游编辑

    //执行接口
    loadUnits(inid, batid) {
      this.loading = true;
      let params = {
        insuranceId: inid,
        batchId: batid
        //policyItemId: "7CC81A51-E404-43F4-B593-F61E2598ADA4"
      };
      if (this.policyItemId){
       	 params.policyItemId = this.policyItemId;
	      }
     if(this.$route.query.filterType){
	        	params.filterType =1
	        	
	       }
      this.post(params, "services/app/policy/GetAllFilter").then(rs => {
       console.log('zhiixngjiejo')
				
        if (rs.success) {
        	console.log(rs)
        	//allhide
        	this.allhide1=true
        	this.allhide2=true
        	for(var i=0;i<rs.result.policyFilter.length;i++){
        		rs.result.policyFilter[i].add_isShow=rs.result.policyFilter[i].isShow
        		if(rs.result.policyFilter[i].conditionType==1){
        			if(rs.result.policyFilter[i].add_isShow==true){
        				this.allhide1=false
        			}
        		}
        		if(rs.result.policyFilter[i].conditionType==2){
        			if(rs.result.policyFilter[i].add_isShow==true){
        				this.allhide2=false
        			}
        		}
        		if(rs.result.policyFilter[i].extends){
        			for(let j=0;j<rs.result.policyFilter[i].extends.length;j++){
        				for(let k=0;k<rs.result.policyFilter[i].extends[j].extendValues.length;k++){
									if(rs.result.policyFilter[i].id == 66){
										this.id66 = rs.result.policyFilter[i].extends[0].extendValues[0].id;
										console.log(this.id66);
									}
									if(rs.result.policyFilter[i].id == 68){
										this.id68 = rs.result.policyFilter[i].extends[0].extendValues[0].id;
										console.log(this.id68);
									}
									if(rs.result.policyFilter[i].id == 58){
										this.id58 = rs.result.policyFilter[i].extends[0].extendValues[0].id;
										console.log(this.id58);
									}
        					if(rs.result.policyFilter[i].extends[j].extendValues[k].isChecked==true){
        						rs.result.policyFilter[i].extends[j].checked_id=rs.result.policyFilter[i].extends[j].extendValues[k].id
        					}
        				}
        			}
        		}
        		
        		if(rs.result.policyFilter[i].displayType=='9'){
        			
        			if(rs.result.policyFilter[i].value&&rs.result.policyFilter[i].value!=""){
        				rs.result.policyFilter[i].addsvalue=rs.result.policyFilter[i].value.split(",")
        			}else{
        				rs.result.policyFilter[i].addsvalue=[]
        			}
        			
        		}
        		
        		
        		
        		
        	}
          let all = rs.result.policyFilter;
          
          this.policyFilter = all;
          this.regions = rs.result.regions;
          for(let i=0;i<this.regions.length;i++){
          	if(i==this.regions.length-1){
          		this.textdires+=this.regions[i].fullName
          	}else{
          		this.textdires+=this.regions[i].fullName+"，"
          	}
          }
          this.allMap(all);
          this.letMap(all);
          this.loading = false;
        }else{
        	this.loading = false;
        	 this.$notify.error({
            title: "错误",
            message: rs.error.message
          });
        }
      });
    },
    letMap(arr) {
    	 console.log('------------------------------')
    	console.log(arr)
      //根据类型分组
      var map = {},
        dest = [];
      for (var i = 0; i < arr.length; i++) {
        var ai = arr[i];
        if (!map[ai.conditionType]) {
          dest.push({
            conditionType: ai.conditionType,
            data: [ai]
          });
          map[ai.conditionType] = ai;
        } else {
          for (var j = 0; j < dest.length; j++) {
            var dj = dest[j];
            if (dj.conditionType == ai.conditionType) {
              dj.data.push(ai);
              break;
            }
          }
        }
      }
	   
	     		var compare = function (obj1, obj2) {
				    var val1 = obj1.conditionType;
				    var val2 = obj2.conditionType;
				    if (val1 < val2) {
				        return -1;
				    } else if (val1 > val2) {
				        return 1;
				    } else {
				        return 0;
				    }            
				} 
				
	     	dest.sort(compare)
      this.newArr = dest;
      
      console.log('------------------------------')
      console.log(dest)
      
      
      
      
      
      // data.map(item => {
      //   console.log(arr)

      //   if (arr.length == 0) {
      //     arr.push({ conditionType: item.conditionType});
      //   } else {
      //     console.log(arr)
      //     arr.map(function(obj, index) {
      //       if (obj.conditionType !== item.conditionType) {
      //        arr.push({conditionType:item.conditionType})
      //        console.log(obj.conditionType+'&&&'+item.conditionType)
      //       }else{

      //       }
      //     });
      //   }
      //     console.log(arr);
      // });
    },
    allMap(data) {
      //遍历
     
      let dds = [];
      let temarr = [];
      var that=this
      data.map(function(item, index) {
        dds.push({
          policyFilterId: item.id,
          conditionValue: item.value
        });
        //扩展信息
        if(item.extends){
        	dds[index].conditionValue = item.value;
        	// filters[index].extendInfo = val;
        	if(item.extends[0].extendValues){
        		// for(let i=0;i<item.extends[0].extendValues.length;i++){ //扩展信息默认传值 extends[0]下的value
        		// 	if(item.extends[0].extendValues[i].isChecked==true){
        		// 		dds[index].extendInfo = item.extends[0].extendValues[i].id
        		// 	}
						// }
						dds[index].extendInfo = item.extends[0].value
        	}
        }
        //shu
        if(item.treeItems){
        			dds[index].conditionValue = item.value;
        			if(item.value){
        				that.arrdefaults= item.value.split(",")
        				that.recursion(that.arrdefaults,item.treeItems)
        			}
        			
        }
        
        //时间
        if(item.dateValues===null){
        	item.dateValues=[]
        	Vue.set(item,"checkedsnow",true)
        }
        if(item.dateValues instanceof Array==true&&item.dateValues.length>=1){
        	console.log(item.dateValues)
        	if(item.dateValues[1]==""||!item.dateValues[1]){
        		//item.checkedsnow=true
        		Vue.set(item,"checkedsnow",true)
        	}else{
        		Vue.set(item,"checkedsnow",false)
        	}
        	
        	let strs="";
        	strs=item.dateValues.join("-")
        	dds[index].conditionValue = strs;
        	console.log("shuchuchuchuchuchcu")
        	console.log(dds[index].conditionValue)
        }
       //投放区域
       
       if(item.policyRegion instanceof Array==true){
       			let addstr=""
	       		for(let i=0;i<item.policyRegion.length;i++){
	       			that.checkboxGroup1.push(item.policyRegion[i].regionType)
	       			if(item.policyRegion[i].regionType==2){
	       				if(item.policyRegion[i].regionId){
	       						addstr+=item.policyRegion[i].regionType+":"+item.policyRegion[i].regionId.join("-")+","
	       						for(let j=0;j<item.policyRegion[i].regionId.length;j++){
		       					that.checkedBs.push(parseFloat(item.policyRegion[i].regionId[j]))
		       					that.now_checkedBs.push(parseFloat(item.policyRegion[i].regionId[j]))
		       					console.log("这i里会不会横越的吊桥的粉碎")
		       				}
	       				}
	       			
	       				
	       			}else if(item.policyRegion[i].regionType==3){
	       				if(item.policyRegion[i].regionId){
	       						addstr+=item.policyRegion[i].regionType+":"+item.policyRegion[i].regionId.join("-")+","
	       						
		       				that.wsselect_add=item.policyRegion[i].parentId
		       				//that.wsselectChange(that.wsselect)
		       				for(let j=0;j<item.policyRegion[i].regionId.length;j++){
		       					that.checkedWs.push(parseFloat(item.policyRegion[i].regionId[j]))
		       				}
	       				}
	       			
	       			}else{
	       				addstr+=item.policyRegion[i].regionType+","
	       			}
	       		}
	       		addstr=addstr.slice(0,addstr.length-1)
	       	
	       		dds[index].conditionValue = addstr;
	       		
       }
       
        if (item.items&&item.items.length>0) {
        	if(item.id==67){
	        			for(let i=0;i<item.items.length;i++){
	        				if(item.items[i].isChecked){
	        					that.insurance_model.push(item.items[i].id)
	        				}
	        				
	        			}
	        	}
        	if(item.id==75){
	        			for(let i=0;i<item.items.length;i++){
	        				if(item.items[i].isChecked){
	        					that.no_insurance_model.push(item.items[i].id)
	        				}
	        				
	        			}
	        	}
          let str = "";
          item.items.map(function(obj) {
          	
            if (obj.isChecked) {
              str += obj.id + ",";
            }
          });
          if (str.length > 0) {
            str=str.slice(0, str.length - 1);
          }
          
          dds[index].conditionValue = str;
        }
        if (item.displayType == 1) {
          temarr.push({
            tarr: []
          });
        } else {
          temarr.push({
            tarr: ""
          });
        }
      });
      this.filters = dds;
      this.temarr = temarr;
     console.log("zuihou")
     console.log(this.filters)
      
    },
    checkGrop(event, index) {
      let filters = this.filters;
      let temarr = this.temarr;
      let dds = "";
      event.map(function(item) {
        dds += item + ",";
      });
      dds.substring(0, dds.length - 1);
      filters[index].conditionValue = dds;
      this.filters = filters;
    },
    radioGrop(event, index) {
    
      let filters = this.filters;
      filters[index].conditionValue = event;
      this.filters = filters;
    },
    minChange(event, index) {
     
      let filters = this.filters;
      let curvalue = filters[index].conditionValue;
      if (curvalue == "" || curvalue.indexOf("-") == -1) {
        filters[index].conditionValue = event;
      } else {
        let ind = curvalue.indexOf("-");
        let b = curvalue.substring(0, ind);
        filters[index].conditionValue = curvalue.replace(b, event);
      
      }
      
    },
    maxChange(event, index) {
      let filters = this.filters;
      let curvalue = filters[index].conditionValue;
      
      if (curvalue && curvalue.indexOf("-") == -1) {
        filters[index].conditionValue = curvalue + "-" + event;
      } else if (curvalue.indexOf("-") !== -1) {
        let ind = curvalue.indexOf("-") + 1;
        let b = curvalue.substring(0, ind) + event;
        filters[index].conditionValue = b;
        
      }
      
    },
    selectChange($event, index) {},
    quyuGrop(event, index) {},
    toufang() {
      let bscheck = this.bscheck;
      let wscheck = this.wscheck;
      let checkedBs = this.checkedBs;
      let checkedWs = this.checkedWs;
      let bdqcheck = this.bdqcheck;
      let qtcheck = this.qtcheck;
      let bdq, qtq, cur;
      let policyFilter = this.policyFilter;
      policyFilter.map(function(item, index) {
        if (item.displayType == 6) {
          cur = index;
        }
      });

      if (bdqcheck.length > 0) {
        bdq = "1,";
      } else {
        bdq = "";
      }
      if (qtcheck.length > 0) {
        qtq = "4";
      } else {
        qtq = "";
      }
      function cons(data, arr) {
        let str;
        if (data.length > 0) {
          str = data[0] + ":";
          if (arr.length > 0) {
            arr.map((item, index) => {
              if (index !== arr.length - 1) {
                str += item + "-";
              } else {
                str += item;
              }
            });
          }
          str = str + ",";
        } else {
          str = "";
        }
        return str;
      }
      let tfqy =
        bdq + cons(bscheck, checkedBs) + cons(wscheck, checkedWs) + qtq;
      let filters = this.filters;
      filters[cur].conditionValue = tfqy;
    },
    getbensheng(){
			let _this = this;
    	//本省按钮点击
      let params = {
        LocalProvince: "1",
        PolicyBatchId: this.batchId
      };
      this.post(params, "services/app/Policy/GetCitysForLocalProvince").then(
        rs => {
          
          if (rs.success) {
						let bslist = rs.result.result;
							if(_this.$route.query.policyId&&!_this.$route.query.iscopy){
								this.bslist = bslist;
							}else if(_this.$route.query.policyId&&_this.$route.query.iscopy){
								this.bslist = bslist;
							}else{
								// let arr=[]
								// arr.push({
								// 	title:"全部",
								// 	childs:bslist,
								// 	id: "quanbu"
								// })
								this.bslist = bslist;
							}
		        
          }
        }
      );
    },
    bensheng() {
    	
	    	this.getbensheng()
	     
	      this.benshengHidden = true;
	       this.checkedBs=this.now_checkedBs
	    	
    	
    },
    //本省其他区域确定
    benshengSave(index) {
      let checkedBs = this.checkedBs;
			this.now_checkedBs=this.checkedBs
			console.log(checkedBs)
      if (checkedBs.length > 0) {
        //checked选项大于0  indexOf
       // this.checkboxGroup1 = [2];
       if(this.checkboxGroup1.indexOf(2)!=-1){
       	
       }else{
       	this.checkboxGroup1.push(2)
       }
      }else{
      	 if(this.checkboxGroup1.indexOf(2)!=-1){
       		let indexs = this.checkboxGroup1.indexOf(2);
	       	this.checkboxGroup1.splice(indexs,1)
	       }else{
	       	
	       }
      }
       let str=this.getstr()
			let filters = this.filters;
				// let nstr ;
				//  nstr = str.replace("-quanbu","")
  		filters[index].conditionValue=str;
      this.benshengHidden = false;
    },
      waishengSave(index) {
      let checkedWs = this.checkedWs;
      if (checkedWs.length > 0) {
        if(this.checkboxGroup1.indexOf(3)!=-1){
       	
       }else{
       	this.checkboxGroup1.push(3)
       }
      }else{
      	if(this.checkboxGroup1.indexOf(3)!=-1){
      		var indexs=this.checkboxGroup1.indexOf(3)
       		this.checkboxGroup1.splice(indexs,1)
       }else{
       	
       }
      }
      let str=this.getstr()
     
      this.wsselect_add=this.wsselect
      this.checkedWs_add=this.checkedWs
  		this.filters[index].conditionValue = str;
      this.waishengHidden = false;
    },
    //本省全选
    checkallbs(val) {
      let bslist = this.bslist;
      let all = this.mapList(bslist);
      this.checkedBs = val ? all : [];
      this.isIndeterminate = false;
    },
    bsChange(value) {
      //本省checkbox点击
      let leng = this.bslist.length;
      let checkedCount = value.length;
      this.bscheckAll = checkedCount === leng;
      this.isIndeterminate = checkedCount > 0 && checkedCount < leng;
    },
    getwaisheng(){
    	console.log("waishenshuju")
    	 let params = {
        LocalProvince: "2",
        PolicyBatchId: this.batchId
      };
      this.post(params, "services/app/Policy/GetCitysForLocalProvince").then(
        rs => {
        	
          if (rs.success) {
						let wslist = rs.result.result;
						// let arr=[]
		        // arr.push({
		        // 	title:"全部",
		        // 	childs:wslist,
		        // 	id: "quanbu"
		        // })
            this.wslist = wslist;
            this.wsselect=this.wsselect_add
            this.wsselectChange(this.wsselect)
          }
        }
      );
    },
    //外省
    waisheng() {
    
    		 var that=this
  	 that.wscheckAll=false
  	 that.wsisIndeterminate=0

    	 new Promise(function(reslove,reject){
	      let params = {
        LocalProvince: "2",
        PolicyBatchId: that.BatchId
      };
      that.post(params, "services/app/Policy/GetCitysForLocalProvince").then(
        rs => {
         
          if (rs.success) {
          	
            let wslist = rs.result.result;
            that.wslist = wslist;
            
            that.wsselect=that.wsselect_add
            that.wsselectChange(that.wsselect)
            reslove()
          }
        }
      )
	     
	     }).then(function(){
	     		that.checkedWs=that.checkedWs_add
	     })
      this.waishengHidden = true;
    	
    	
    },
    //外省其他区域确定
  
    //外省全选
    checkallws(val) {
    	
      let wsarr = this.wsarr;
      let all = this.wsmapList(wsarr);
      this.checkedWs = val ? all : [];
      this.wsisIndeterminate = false;
    },
    wsChange(value) {
      //外省checkbox点击
      let leng = this.wsarr.length;
      let checkedCount = value.length;
      this.wscheckAll = checkedCount === leng;
      this.wsisIndeterminate = checkedCount > 0 && checkedCount < leng;
    },
    wsselectChange(val) {
    	//checkedWs
    	let arr=[]
      this.checkedWs = arr;
      this.wscheckAll = false;
      const me = this;
      let params = {
        id: val
      };
      if(val.length!==0){
      	 this.post(params, "services/app/common/GetRegions").then(rs => {
      	
        if (rs.success) {
          let wsarr = rs.result.items;
          me.wsarr = wsarr;
          
        }
      });
      }else{
      	let wsarr =[];
          me.wsarr = wsarr;
      }
     
    },
    mapList(data) {
      let all = [];
      data.map(item => {
        all.push(item.id);
      });
      return all;
    },
    wsmapList(data) {
      let all = [];
      data.map(item => {
        all.push(item.key);
      });
      return all;
    },

    //时间change
    dateChange(event, index) {
     if(this.policyFilter[index].dateValues[1]&&this.policyFilter[index].dateValues[0]){
      let start=new Date(this.policyFilter[index].dateValues[0])
    	let end=new Date(this.policyFilter[index].dateValues[1])
    	console.log(start.getTime())
    	if(end.getTime()<start.getTime()){
    			  this.$message({
		          showClose: true,
		          message: '结束时间不能小于开始时间',
		          type: 'warning'
		        });
    			Vue.set(this.policyFilter[index].dateValues,1,"")
    	}
     
     }
     let startarr=(this.policyFilter[index].dateValues[0]==null||this.policyFilter[index].dateValues[0]=='undefined'||this.policyFilter[index].dateValues[0]=='')?' ':this.policyFilter[index].dateValues[0]
     let ndate=""
     if(this.policyFilter[index].dateValues[1]&&this.policyFilter[index].dateValues[1]!=''){
     		Vue.set(this.policyFilter[index],"checkedsnow",false)
     	  ndate = startarr + "-" + this.policyFilter[index].dateValues[1];
     }else{
     	  ndate = startarr + "-" 
     }
    
    
     let filters = this.filters;
     filters[index].conditionValue = ndate; 
      console.log(ndate)
    },
    radiochange(event, index){
    	console.log(event)
    	let startarr=(this.policyFilter[index].dateValues[0]==null||this.policyFilter[index].dateValues[0]=='undefined'||this.policyFilter[index].dateValues[0]=='')?' ':this.policyFilter[index].dateValues[0]
     let ndate=""
    	if(event==true){
    		Vue.set(this.policyFilter[index].dateValues,1,"")
    		ndate = startarr + "-" 
    		let filters = this.filters;
    		filters[index].conditionValue = ndate; 
    		 console.log(ndate)
    	}
    	
    }
  }
};
</script>

<style lang="scss" scoped>
.wd80 {
  width: 80px;
}
.policy-box {
  padding: 30px 25px 20px;
  width:100%;
  color:#000;
}

.ft13 {
  font-size: 13px;
  padding-right: 10px;
}
.mmerror .el-input__inner {
  border: 1px solid #f56c6c;
}

.isExpand_ben{
	width:100%;
	text-align:center;
}
.isExpand,.isnExpand{
	text-align:center;
	p{
		height: 0px;
	    display: block;
	    border: 0.5px solid #cbcbcb;
	    position: relative;
	    top: -31px;
	    z-index:0;
	}
	img{
		z-index: 2;
		position:relative;
		cursor:pointer;
	}
}
.isnExpand{
	p{
		top: -23px;
	}
}
.show{
	/*min-height:780px;
	overflow:hidden;*/
	transition:all 1s;
}
.hide{
	/*min-height:572px;
	overflow:hidden;*/
	transition:all 1s;
}
.Expandshow{
	/*height:1099px;
	overflow:hidden;*/
	transition:height 1s;
}
.Expandhide{
	/*height:643px;
	overflow:hidden;*/
	height:auto;
}
.checkregion{
	width:200px;
	display:flex;
	flex-direction: column;
	align-items: flex-start;
	position:relative;
	.posone{
		display:block;
		position:absolute;
		top:0;
		left:240px;
		width:800px;
	
		font-size:13px;
		margin:0;
		text-indent:0;
		text-align:left;
		overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
	}
	.posone_true{
		color:#666;
	}
	.posone_false{
		color:#000;
	}
	.postwo{
		position:absolute;
		width:200px;
		top:34px;
		left:240px;
	}
		.posthree{
				width:230px;
		position:absolute;
		top:66px;
		left:240px;
		padding:0 30px 0 0;
		text-align:left;
		margin-left:0;
	}
}
.carname{
	color:#606266;
	font-size:13px;
	margin-top:20px;
	p{
		padding:0;
		float:left;
		border:1px solid #409EFF;
		margin:0;
		padding:0 15px;
		background:white;
		color:#409EFF;
		border-radius:4px;
		margin-right:10px;
		margin-bottom:12px;
	}
}
.util-table {
					border: 0;
					border-collapse: collapse;
					
					tr {
						th {
							background: #334750;
							color: #fff;
							
							text-align: center;
						}
						td {
									padding: 0;
									font-size: 14px;
									border-bottom: double #e8e8e8;
									height:44px;
									text-align:center;
								}
					}
				
}
.policy_box_top{
	width:100%;
	height:60px;
	text-align:center;
	font-size: 18px;
	color: #333333;
	line-height:60px;
	border-bottom: 1px solid #FF7819;
	position:relative;
	.backgo{
		position:absolute;
		height:60px;
		width:60px;
		line-height:60px;
		font-size: 16px;
		color: #FF7819;
		top:0;
		left:23px;
		padding:0;
		margin:0;
		cursor:pointer;
	}
	i{
		margin-right:10px;
		color: #ee6000
	}
}


.form_left{
	width:140px;
	position:absolute;
	top:0;
	left:0;
	font-size: 18px;
	color: #333333;
	letter-spacing: 2px;
	text-align:center;
}
.form_right{
	background: #f9f9f9;
	padding-top:22px;
	padding-bottom:22px;
	.form_right_one{
		width:300px;
		float:left;
		
	}
}
.more{
	font-size: 14px;
	color: #027DCA;
	cursor:pointer;
}
.bomfixed{
	width:100%;
	height:72px;
	position:fixed;
	bottom:0;
	left:0;
	z-index:33;
	padding-left:200px;
	padding-right:52px;
	background:#F9F9F9;
	border-top: 1px solid #ddd;
	.bomfixed_content{
		
			
		height:72px;
		
		line-height:72px;
	}
}
.bomfixed_left{
	padding-top:22px;
	float:left;
	width:60%;
	
}
.bomfixed_right{
	padding-top:22px;
	float:right;
	
}
.el-checkbox{
	color:#000;
}
.selets_models{
	width:500px;
}
.wd230_110{
	width:100px;
	margin-left:10px;
}
.addbtn{
	color: #027DCA;
	cursor:pointer;
	.addbtnedits{
		margin-right:5px;
	}
}
.inputset{
							background: #FAFAFA;
							border: 1px solid #CBCBCB;
							width:45px;
							height:21px;
							text-align: right;
							color:#333333;
							font-size:12px;
							padding:3px;
							outline:none;
							border-radius:4px;
						}
			.backshows{
		background: rgba(249,225,202,0.50);
	}		
	.ischange1 input{
		border:1px solid #FF9430;
	}
	.ischange2 input{
		border:1px solid #FF9430;
	}
	.ischange3 input{
		border:1px solid #FF9430;
	}
	.ischange4 input{
		border:1px solid #FF9430;
	}	
	.ischange5 input{
		border:1px solid #FF9430;
	}	
	.isfrontshow,.isseconshow,.isthreeshow{
		border:1px solid red!important;
	}
	.content {
		width: 100%;
	
		overflow: auto;
		font-size: 12px;
	}
	.inputs {
		width: 250px;
		font-size: 12px;
	}
	.numcontent {
		width: 250px;
		font-size: 12px;
		display:flex;
		justify-content: space-between;
	}
	.numinp {
		width: 60px;
		margin-left: 5px;
		height:28px;
		border-radius: 4px;
		outline:none;
   		 border: 1px solid #dcdfe6;
   		 padding-left:5px;
	}
	.btns {
		display: flex;
		justify-content: center;
		margin-left:-150px;
		margin-top:30px;
	}
	.actives .numinp{
		border:1px solid red;
	}
	.actives_tuo .numinp{
		border:1px solid red;
	}
	.el-radio-button:focus:not(.is-focus):not(:active){
		box-shadow: none;
	}
	.yichu{
		span{
			display:block;
			width:100%;
		height:44px;
		line-height:44px;
    padding: 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
		}
		
	}
	.isdis{
		    background-color: #f5f7fa;
			    border-color: #e4e7ed;
			    color: #c0c4cc;
			    cursor: not-allowed;
			    color:#333;
			}
			.nodata{
				width:100%;
				text-align:center;
				margin-bottom:20px;
				color:#999;
			}
			.datesclass{
				width:120px;
				padding:0;
			}
</style>

